diff --git a/apps/explorer/src/components/AddressesCardGraph.tsx b/apps/explorer/src/components/AddressesCardGraph.tsx index 3258b556573..0c5ba23db08 100644 --- a/apps/explorer/src/components/AddressesCardGraph.tsx +++ b/apps/explorer/src/components/AddressesCardGraph.tsx @@ -8,7 +8,8 @@ import { useMemo } from 'react'; import { useGetAddressMetrics } from '~/hooks/useGetAddressMetrics'; import { useGetAllEpochAddressMetrics } from '~/hooks/useGetAllEpochAddressMetrics'; import { LabelTextSize, TooltipPosition } from '@iota/apps-ui-kit'; -import { StatisticsPanel, GraphTooltip } from './StatisticsPanel'; +import { StatisticsPanel } from './StatisticsPanel'; +import { GraphTooltipContent } from './GraphTooltipContent'; const GRAPH_DATA_FIELD = 'cumulativeAddresses'; const GRAPH_DATA_TEXT = 'Total addresses'; @@ -18,7 +19,13 @@ function TooltipContent({ data }: { data: AllEpochsAddressMetrics[number] }): JS const totalFormatted = formatAmount(data[GRAPH_DATA_FIELD]); const overline = `${dateFormatted}, Epoch ${data.epoch}`; - return ; + return ( + + ); } const FALLBACK = '--'; diff --git a/apps/explorer/src/components/AreaGraph.tsx b/apps/explorer/src/components/AreaGraph.tsx index ebfc5f690f5..dd3723c03d0 100644 --- a/apps/explorer/src/components/AreaGraph.tsx +++ b/apps/explorer/src/components/AreaGraph.tsx @@ -13,7 +13,7 @@ import { bisector, extent } from 'd3-array'; import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from 'react'; import { throttle } from 'throttle-debounce'; -import { GraphTooltipContent } from './GraphTooltipContent'; +import { GraphTooltipContainer } from './GraphTooltipContent'; let idCounter = 0; @@ -129,21 +129,33 @@ export function AreaGraph({ offsetTop={0} left={tooltipLeft} top={tooltipTopAdj} - className="pointer-events-none absolute z-10 h-0 w-max overflow-visible" + className="pointer-events-none absolute z-10 h-0 w-max overflow-visible bg-black" unstyled detectBounds > - {tooltipContent(tooltipContentProps)} + + {tooltipContent(tooltipContentProps)} + ) : null} - - + + - + diff --git a/apps/explorer/src/components/GraphTooltipContent.tsx b/apps/explorer/src/components/GraphTooltipContent.tsx index ddceab1776c..515c04990b7 100644 --- a/apps/explorer/src/components/GraphTooltipContent.tsx +++ b/apps/explorer/src/components/GraphTooltipContent.tsx @@ -4,18 +4,13 @@ import { useTooltipPosition } from '@visx/tooltip'; import clsx from 'clsx'; -import { type ReactNode } from 'react'; -type GraphTooltipContentProps = { - children: ReactNode; -}; - -export function GraphTooltipContent({ children }: GraphTooltipContentProps): JSX.Element { +export function GraphTooltipContainer({ children }: React.PropsWithChildren): JSX.Element { const { isFlippedHorizontally } = useTooltipPosition(); return (
); } + +interface GraphTooltipContentProps { + title: string; + overline: string; + subtitle: string; +} +export function GraphTooltipContent({ title, overline, subtitle }: GraphTooltipContentProps) { + return ( +
+ {overline} + {title} + {subtitle} +
+ ); +} diff --git a/apps/explorer/src/components/StatisticsPanel.tsx b/apps/explorer/src/components/StatisticsPanel.tsx index b2701d4b6d6..b30be733170 100644 --- a/apps/explorer/src/components/StatisticsPanel.tsx +++ b/apps/explorer/src/components/StatisticsPanel.tsx @@ -69,18 +69,3 @@ export function StatisticsPanel({ ); } - -interface GraphTooltipProps { - title: string; - overline: string; - subtitle: string; -} -export function GraphTooltip({ title, overline, subtitle }: GraphTooltipProps) { - return ( -
- {overline} - {title} - {subtitle} -
- ); -} diff --git a/apps/explorer/src/components/TransactionsCardGraph.tsx b/apps/explorer/src/components/TransactionsCardGraph.tsx index 510f5785b7c..ee9f1a8679a 100644 --- a/apps/explorer/src/components/TransactionsCardGraph.tsx +++ b/apps/explorer/src/components/TransactionsCardGraph.tsx @@ -5,7 +5,8 @@ import { CoinFormat, formatAmount, formatBalance, formatDate } from '@iota/core'; import { useIotaClientQuery } from '@iota/dapp-kit'; import { LabelTextSize, TooltipPosition } from '@iota/apps-ui-kit'; -import { GraphTooltip, StatisticsPanel } from './StatisticsPanel'; +import { StatisticsPanel } from './StatisticsPanel'; +import { GraphTooltipContent } from './GraphTooltipContent'; interface TooltipContentProps { data: { @@ -24,7 +25,11 @@ function TooltipContent({ const overline = `${dateFormatted}, Epoch ${epoch}`; return ( - + ); } diff --git a/apps/explorer/src/components/top-packages/TopPackagesCard.tsx b/apps/explorer/src/components/top-packages/TopPackagesCard.tsx index 9a172b38586..0ead5efec72 100644 --- a/apps/explorer/src/components/top-packages/TopPackagesCard.tsx +++ b/apps/explorer/src/components/top-packages/TopPackagesCard.tsx @@ -11,17 +11,17 @@ import { ErrorBoundary } from '../error-boundary/ErrorBoundary'; import { TopPackagesTable } from './TopPackagesTable'; import { Panel, Title } from '@iota/apps-ui-kit'; -type DateFilter = '3D' | '7D' | '30D'; +type DateFilter = '3d' | '1w' | '1m'; type ApiDateFilter = 'rank3Days' | 'rank7Days' | 'rank30Days'; export const FILTER_TO_API_FILTER: Record = { - '3D': 'rank3Days', - '7D': 'rank7Days', - '30D': 'rank30Days', + '3d': 'rank3Days', + '1w': 'rank7Days', + '1m': 'rank30Days', }; export function TopPackagesCard(): JSX.Element { const rpc = useEnhancedRpcClient(); - const [selectedFilter, setSelectedFilter] = useState('3D'); + const [selectedFilter, setSelectedFilter] = useState('3d'); const { data, isPending } = useQuery({ queryKey: ['top-packages', selectedFilter], @@ -35,9 +35,10 @@ export function TopPackagesCard(): JSX.Element {
setSelectedFilter(val)} + filtersAsChip />
<ErrorBoundary> - <TopPackagesTable data={filteredData} isLoading={isPending} /> + <div className="p-md--rs"> + <TopPackagesTable data={filteredData} isLoading={isPending} /> + </div> </ErrorBoundary> </div> </Panel> diff --git a/apps/explorer/src/components/ui/FilterList.tsx b/apps/explorer/src/components/ui/FilterList.tsx index bb4771910b2..1f0fd48bc90 100644 --- a/apps/explorer/src/components/ui/FilterList.tsx +++ b/apps/explorer/src/components/ui/FilterList.tsx @@ -5,23 +5,27 @@ // TODO: This component really shouldn't use the `Tabs` component, it should just use radix, // and should define it's own styles since the concerns here are pretty different. -import { ButtonSegment, SegmentedButton } from '@iota/apps-ui-kit'; +import { ButtonSegment, SegmentedButton, Chip } from '@iota/apps-ui-kit'; export interface FilterListProps<T extends string = string> { selected: T; options: readonly T[]; onSelected(value: T): void; + filtersAsChip?: boolean; } export function FilterList<T extends string>({ options, selected, onSelected, + filtersAsChip, }: FilterListProps<T>): JSX.Element { + const FilterComponent = filtersAsChip ? Chip : ButtonSegment; + return ( <SegmentedButton> {options.map((option) => ( - <ButtonSegment + <FilterComponent key={option} label={option} selected={option == selected}