diff --git a/libs/network-stats/src/components/good-threshold-indicator/good-threshold-indicator.tsx b/libs/network-stats/src/components/good-threshold-indicator/good-threshold-indicator.tsx deleted file mode 100644 index 0e7d517c2..000000000 --- a/libs/network-stats/src/components/good-threshold-indicator/good-threshold-indicator.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import type { value, goodThreshold } from '../../config/types'; - -interface GoodThresholdIndicatorProps { - goodThreshold: goodThreshold | undefined; - value: value; -} - -export const GoodThresholdIndicator = ({ - goodThreshold, - value, -}: GoodThresholdIndicatorProps) => { - return ( -
- ); -}; diff --git a/libs/network-stats/src/components/good-threshold-indicator/index.ts b/libs/network-stats/src/components/good-threshold-indicator/index.ts deleted file mode 100644 index 6ffd483b7..000000000 --- a/libs/network-stats/src/components/good-threshold-indicator/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { GoodThresholdIndicator } from './good-threshold-indicator'; diff --git a/libs/network-stats/src/components/promoted-stats-item/promoted-stats-item.tsx b/libs/network-stats/src/components/promoted-stats-item/promoted-stats-item.tsx index 8e1fe15b4..d36fac649 100644 --- a/libs/network-stats/src/components/promoted-stats-item/promoted-stats-item.tsx +++ b/libs/network-stats/src/components/promoted-stats-item/promoted-stats-item.tsx @@ -1,7 +1,8 @@ import { Tooltip } from '@vegaprotocol/ui-toolkit'; import type { StatFields } from '../../config/types'; import { defaultFieldFormatter } from '../table-row'; -import { GoodThresholdIndicator } from '../good-threshold-indicator'; +import { Card, Indicator, Variant } from '@vegaprotocol/ui-toolkit'; +import { useMemo } from 'react'; export const PromotedStatsItem = ({ title, @@ -10,17 +11,26 @@ export const PromotedStatsItem = ({ value, description, }: StatFields) => { + const variant = useMemo( + () => + goodThreshold + ? goodThreshold(value) + ? Variant.Success + : Variant.Danger + : Variant.Highlight, + [goodThreshold, value] + ); return ( -
+
- + {title}
{formatter ? formatter(value) : defaultFieldFormatter(value)}
-
+
); }; diff --git a/libs/network-stats/src/components/stats-manager/stats-manager.tsx b/libs/network-stats/src/components/stats-manager/stats-manager.tsx index 302503e98..17bf335df 100644 --- a/libs/network-stats/src/components/stats-manager/stats-manager.tsx +++ b/libs/network-stats/src/components/stats-manager/stats-manager.tsx @@ -9,6 +9,7 @@ import { Table } from '../table'; import { TableRow } from '../table-row'; import { PromotedStats } from '../promoted-stats'; import { PromotedStatsItem } from '../promoted-stats-item'; +import { Card } from '@vegaprotocol/ui-toolkit'; interface StatsManagerProps { envName: string; diff --git a/libs/network-stats/src/components/table-row/table-row.tsx b/libs/network-stats/src/components/table-row/table-row.tsx index 249ff4e79..acae03ab3 100644 --- a/libs/network-stats/src/components/table-row/table-row.tsx +++ b/libs/network-stats/src/components/table-row/table-row.tsx @@ -1,6 +1,7 @@ import { Tooltip } from '@vegaprotocol/ui-toolkit'; import type { StatFields } from '../../config/types'; -import { GoodThresholdIndicator } from '../good-threshold-indicator'; +import { useMemo } from 'react'; +import { Indicator, Variant } from '@vegaprotocol/ui-toolkit'; export const defaultFieldFormatter = (field: unknown) => field === undefined ? 'no data' : field; @@ -12,6 +13,15 @@ export const TableRow = ({ value, description, }: StatFields) => { + const variant = useMemo( + () => + goodThreshold + ? goodThreshold(value) + ? Variant.Success + : Variant.Danger + : Variant.Highlight, + [goodThreshold, value] + ); return ( @@ -20,7 +30,7 @@ export const TableRow = ({ {formatter ? formatter(value) : defaultFieldFormatter(value)} - +