add isMobile truncation logic to ListTable
This commit is contained in:
@@ -4,7 +4,7 @@ import { useSpring, config } from '@react-spring/web';
|
|||||||
import { Grid, Row, Column, Text } from '@umami/react-zen';
|
import { Grid, Row, Column, Text } from '@umami/react-zen';
|
||||||
import { AnimatedDiv } from '@/components/common/AnimatedDiv';
|
import { AnimatedDiv } from '@/components/common/AnimatedDiv';
|
||||||
import { Empty } from '@/components/common/Empty';
|
import { Empty } from '@/components/common/Empty';
|
||||||
import { useMessages } from '@/components/hooks';
|
import { useMessages, useMobile } from '@/components/hooks';
|
||||||
import { formatLongCurrency, formatLongNumber } from '@/lib/format';
|
import { formatLongCurrency, formatLongNumber } from '@/lib/format';
|
||||||
|
|
||||||
const ITEM_SIZE = 30;
|
const ITEM_SIZE = 30;
|
||||||
@@ -42,6 +42,7 @@ export function ListTable({
|
|||||||
currency,
|
currency,
|
||||||
}: ListTableProps) {
|
}: ListTableProps) {
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
|
const { isMobile } = useMobile();
|
||||||
|
|
||||||
const getRow = (row: ListData, index: number) => {
|
const getRow = (row: ListData, index: number) => {
|
||||||
const { label, count, percent } = row;
|
const { label, count, percent } = row;
|
||||||
@@ -56,6 +57,7 @@ export function ListTable({
|
|||||||
showPercentage={showPercentage}
|
showPercentage={showPercentage}
|
||||||
change={renderChange ? renderChange(row, index) : null}
|
change={renderChange ? renderChange(row, index) : null}
|
||||||
currency={currency}
|
currency={currency}
|
||||||
|
isMobile={isMobile}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -99,6 +101,7 @@ const AnimatedRow = ({
|
|||||||
animate,
|
animate,
|
||||||
showPercentage = true,
|
showPercentage = true,
|
||||||
currency,
|
currency,
|
||||||
|
isMobile,
|
||||||
}) => {
|
}) => {
|
||||||
const props = useSpring({
|
const props = useSpring({
|
||||||
width: percent,
|
width: percent,
|
||||||
@@ -117,7 +120,7 @@ const AnimatedRow = ({
|
|||||||
gap
|
gap
|
||||||
>
|
>
|
||||||
<Row alignItems="center">
|
<Row alignItems="center">
|
||||||
<Text truncate={true} style={{ maxWidth: '400px' }}>
|
<Text truncate={true} style={{ maxWidth: isMobile ? '200px' : '400px' }}>
|
||||||
{label}
|
{label}
|
||||||
</Text>
|
</Text>
|
||||||
</Row>
|
</Row>
|
||||||
|
|||||||
Reference in New Issue
Block a user