diff --git a/package.json b/package.json index b56e9a1..6745467 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,9 @@ "prepare": "husky install", "build:icons": "svgr svgs/resources/ --config-file svgs/configs/.svgrrc.default.cjs && prettier -w ./components/icons" }, + "engines": { + "node": "20.x" + }, "dependencies": { "@artsy/fresnel": "^7.1.3", "@lingui/react": "^4.11.4", diff --git a/src/components/common/Footer/Footer.constants.ts b/src/components/common/Footer/Footer.constants.ts index f92982d..370c39f 100644 --- a/src/components/common/Footer/Footer.constants.ts +++ b/src/components/common/Footer/Footer.constants.ts @@ -53,6 +53,12 @@ export const documentation: ListItemProps[] = [ title: 'Widget Playground', openInNewTab: true, }, + { + location: '', + title: 'Cookie Setting', + className: 'cky-banner-element', + openInNewTab: false, + }, ]; export const socialMedia: ListItemProps[] = [ diff --git a/src/components/common/Footer/Footer.type.ts b/src/components/common/Footer/Footer.type.ts index 0026c1e..72f9cda 100644 --- a/src/components/common/Footer/Footer.type.ts +++ b/src/components/common/Footer/Footer.type.ts @@ -5,4 +5,5 @@ export interface ListItemProps { openInNewTab: boolean; title: string; icon?: React.ComponentType; + className?: string; } diff --git a/src/components/common/Footer/ListItem.tsx b/src/components/common/Footer/ListItem.tsx index d551f74..98f35d9 100644 --- a/src/components/common/Footer/ListItem.tsx +++ b/src/components/common/Footer/ListItem.tsx @@ -2,14 +2,14 @@ import Link from 'next/link'; import { ListItemProps } from './Footer.type'; function ListItem(props: ListItemProps) { - const { title, openInNewTab, location, icon: Icon } = props; + const { title, openInNewTab, location, className, icon: Icon } = props; return (
  • {Icon && } {title} diff --git a/src/components/common/Table/cells/TokenCell.tsx b/src/components/common/Table/cells/TokenCell.tsx index 2dcda6e..6affc5d 100644 --- a/src/components/common/Table/cells/TokenCell.tsx +++ b/src/components/common/Table/cells/TokenCell.tsx @@ -1,10 +1,22 @@ /* eslint-disable @next/next/no-img-element */ +'use client'; + import { DEFAULT_TOKEN_LOGO } from 'src/constant'; import { CellProps } from '../Table.type'; +import { InfoIcon } from 'src/components/icons'; +import Tooltip from '../../Tooltip'; +import { useRef } from 'react'; +import useIsTruncated from 'src/hooks/useIsTruncated'; function TokenCell(props: CellProps) { const { swapItem, column } = props; const { stepsSummary } = swapItem; + const amountRef = useRef(null); + const tokenNameRef = useRef(null); + + const showAmountTooltip = useIsTruncated(amountRef); + const showTokenNameTooltip = useIsTruncated(tokenNameRef); + const firstStep = stepsSummary.length ? stepsSummary[0] : null; const lastStep = stepsSummary.length ? stepsSummary[stepsSummary.length - 1] @@ -19,6 +31,13 @@ function TokenCell(props: CellProps) { const { shortName: blockchainShortName, logo: blockchainLogo } = blockchainData || {}; + const amount = token?.realAmount || token?.expectedAmount; + + const roundedAmount = parseFloat( + Number(token?.realAmount || token?.expectedAmount).toFixed(3), + ); + const tokenName = symbol || name; + return ( <> {column.tokenType === 'source' ? ( @@ -26,7 +45,7 @@ function TokenCell(props: CellProps) { ) : (
    )} -
    +
    -
    -
    - - {`${!token?.realAmount ? '~' : ''}${parseFloat( - Number(token?.realAmount || token?.expectedAmount).toFixed(3), - )}`} - - - {symbol || name} - +
    +
    +
    + + {`${!token?.realAmount ? '~' : ''}${roundedAmount}`} + + {amount && showAmountTooltip && ( + + + + )} +
    +
    + + {tokenName} + + {tokenName && showTokenNameTooltip && ( + + + + )} +
    {blockchainShortName} diff --git a/src/hooks/useIsTruncated.ts b/src/hooks/useIsTruncated.ts new file mode 100644 index 0000000..22c2cb3 --- /dev/null +++ b/src/hooks/useIsTruncated.ts @@ -0,0 +1,22 @@ +import { useEffect, useState, RefObject } from 'react'; + +function useIsTruncated(ref: RefObject): boolean { + const [isTruncated, setIsTruncated] = useState(false); + + useEffect(() => { + const element = ref.current; + if (!element) return; + + const resizeObserver = new ResizeObserver(() => { + setIsTruncated(element.scrollWidth > element.clientWidth); + }); + + resizeObserver.observe(element); + + return () => resizeObserver.disconnect(); + }, [ref]); + + return isTruncated; +} + +export default useIsTruncated;