Commit f0fd62a0 authored by tom's avatar tom

tooltip fixes

parent 730d6ddb
...@@ -20,7 +20,7 @@ export const Tooltip = React.forwardRef<HTMLDivElement, TooltipProps>( ...@@ -20,7 +20,7 @@ export const Tooltip = React.forwardRef<HTMLDivElement, TooltipProps>(
const { const {
showArrow: showArrowProp, showArrow: showArrowProp,
onOpenChange, onOpenChange,
visual, variant,
selected, selected,
children, children,
disabled, disabled,
...@@ -38,7 +38,6 @@ export const Tooltip = React.forwardRef<HTMLDivElement, TooltipProps>( ...@@ -38,7 +38,6 @@ export const Tooltip = React.forwardRef<HTMLDivElement, TooltipProps>(
const [ open, setOpen ] = React.useState(defaultOpen); const [ open, setOpen ] = React.useState(defaultOpen);
const isMobile = useIsMobile(); const isMobile = useIsMobile();
// TODO @tom2drum merge refs
const triggerRef = useClickAway<HTMLButtonElement>(() => setOpen(false)); const triggerRef = useClickAway<HTMLButtonElement>(() => setOpen(false));
const handleOpenChange = React.useCallback((details: { open: boolean }) => { const handleOpenChange = React.useCallback((details: { open: boolean }) => {
...@@ -52,7 +51,7 @@ export const Tooltip = React.forwardRef<HTMLDivElement, TooltipProps>( ...@@ -52,7 +51,7 @@ export const Tooltip = React.forwardRef<HTMLDivElement, TooltipProps>(
if (disabled || (disableOnMobile && isMobile)) return children; if (disabled || (disableOnMobile && isMobile)) return children;
const defaultShowArrow = visual === 'popover' ? false : true; const defaultShowArrow = variant === 'popover' ? false : true;
const showArrow = showArrowProp !== undefined ? showArrowProp : defaultShowArrow; const showArrow = showArrowProp !== undefined ? showArrowProp : defaultShowArrow;
const positioning = { const positioning = {
...@@ -70,7 +69,7 @@ export const Tooltip = React.forwardRef<HTMLDivElement, TooltipProps>( ...@@ -70,7 +69,7 @@ export const Tooltip = React.forwardRef<HTMLDivElement, TooltipProps>(
open={ open } open={ open }
onOpenChange={ isMobile ? undefined : handleOpenChange } onOpenChange={ isMobile ? undefined : handleOpenChange }
closeOnClick={ false } closeOnClick={ false }
visual={ visual } variant={ variant }
lazyMount={ lazyMount } lazyMount={ lazyMount }
unmountOnExit={ unmountOnExit } unmountOnExit={ unmountOnExit }
{ ...rest } { ...rest }
......
...@@ -34,7 +34,7 @@ export const recipe = defineSlotRecipe({ ...@@ -34,7 +34,7 @@ export const recipe = defineSlotRecipe({
}, },
}, },
variants: { variants: {
visual: { variant: {
regular: { regular: {
content: { content: {
'--tooltip-bg': 'colors.tooltip.bg', '--tooltip-bg': 'colors.tooltip.bg',
...@@ -79,6 +79,6 @@ export const recipe = defineSlotRecipe({ ...@@ -79,6 +79,6 @@ export const recipe = defineSlotRecipe({
}, },
}, },
defaultVariants: { defaultVariants: {
visual: 'regular', variant: 'regular',
}, },
}); });
...@@ -517,13 +517,11 @@ const BlockDetails = ({ query }: Props) => { ...@@ -517,13 +517,11 @@ const BlockDetails = ({ query }: Props) => {
</Skeleton> </Skeleton>
{ !txFees.isEqualTo(ZERO) && ( { !txFees.isEqualTo(ZERO) && (
<Tooltip content="Burnt fees / Txn fees * 100%"> <Tooltip content="Burnt fees / Txn fees * 100%">
<Box> <Utilization
<Utilization ml={ 4 }
ml={ 4 } value={ burntFees.dividedBy(txFees).toNumber() }
value={ burntFees.dividedBy(txFees).toNumber() } isLoading={ isPlaceholderData }
isLoading={ isPlaceholderData } />
/>
</Box>
</Tooltip> </Tooltip>
) } ) }
</DetailsInfoItem.Value> </DetailsInfoItem.Value>
......
...@@ -73,9 +73,7 @@ const BlockDetailsBlobInfo = ({ data }: Props) => { ...@@ -73,9 +73,7 @@ const BlockDetailsBlobInfo = ({ data }: Props) => {
{ burntBlobFees.dividedBy(WEI).toFixed() } { currencyUnits.ether } { burntBlobFees.dividedBy(WEI).toFixed() } { currencyUnits.ether }
{ !blobFees.isEqualTo(ZERO) && ( { !blobFees.isEqualTo(ZERO) && (
<Tooltip content="Blob burnt fees / Txn fees * 100%"> <Tooltip content="Blob burnt fees / Txn fees * 100%">
<div> <Utilization ml={ 4 } value={ burntBlobFees.dividedBy(blobFees).toNumber() }/>
<Utilization ml={ 4 } value={ burntBlobFees.dividedBy(blobFees).toNumber() }/>
</div>
</Tooltip> </Tooltip>
) } ) }
</DetailsInfoItem.Value> </DetailsInfoItem.Value>
......
import { Flex, Box } from '@chakra-ui/react'; import { Flex } from '@chakra-ui/react';
import BigNumber from 'bignumber.js'; import BigNumber from 'bignumber.js';
import React from 'react'; import React from 'react';
...@@ -121,9 +121,7 @@ const BlocksTableItem = ({ data, isLoading, enableTimeIncrement, animation }: Pr ...@@ -121,9 +121,7 @@ const BlocksTableItem = ({ data, isLoading, enableTimeIncrement, animation }: Pr
</Skeleton> </Skeleton>
</Flex> </Flex>
<Tooltip content="Burnt fees / Txn fees * 100%" disabled={ isLoading }> <Tooltip content="Burnt fees / Txn fees * 100%" disabled={ isLoading }>
<Box w="min-content"> <Utilization mt={ 2 } w="min-content" value={ burntFees.div(txFees).toNumber() } isLoading={ isLoading }/>
<Utilization mt={ 2 } value={ burntFees.div(txFees).toNumber() } isLoading={ isLoading }/>
</Box>
</Tooltip> </Tooltip>
</TableCell> </TableCell>
) } ) }
......
...@@ -28,6 +28,7 @@ import ButtonShowcase from 'ui/showcases/Button'; ...@@ -28,6 +28,7 @@ import ButtonShowcase from 'ui/showcases/Button';
import LinksShowcase from 'ui/showcases/Links'; import LinksShowcase from 'ui/showcases/Links';
import PaginationShowcase from 'ui/showcases/Pagination'; import PaginationShowcase from 'ui/showcases/Pagination';
import TabsShowcase from 'ui/showcases/Tabs'; import TabsShowcase from 'ui/showcases/Tabs';
import TooltipsShowcase from 'ui/showcases/Tooltip';
const TEXT = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'; const TEXT = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
...@@ -58,6 +59,7 @@ const ChakraShowcases = () => { ...@@ -58,6 +59,7 @@ const ChakraShowcases = () => {
<TabsTrigger value="links">Links</TabsTrigger> <TabsTrigger value="links">Links</TabsTrigger>
<TabsTrigger value="pagination">Pagination</TabsTrigger> <TabsTrigger value="pagination">Pagination</TabsTrigger>
<TabsTrigger value="tabs">Tabs</TabsTrigger> <TabsTrigger value="tabs">Tabs</TabsTrigger>
<TabsTrigger value="tooltips">Tooltips</TabsTrigger>
<TabsTrigger value="unsorted">Unsorted</TabsTrigger> <TabsTrigger value="unsorted">Unsorted</TabsTrigger>
</TabsList> </TabsList>
<AlertsShowcase/> <AlertsShowcase/>
...@@ -66,6 +68,7 @@ const ChakraShowcases = () => { ...@@ -66,6 +68,7 @@ const ChakraShowcases = () => {
<LinksShowcase/> <LinksShowcase/>
<TabsShowcase/> <TabsShowcase/>
<PaginationShowcase/> <PaginationShowcase/>
<TooltipsShowcase/>
<TabsContent value="unsorted"> <TabsContent value="unsorted">
<VStack align="flex-start" gap={ 6 }> <VStack align="flex-start" gap={ 6 }>
...@@ -153,18 +156,6 @@ const ChakraShowcases = () => { ...@@ -153,18 +156,6 @@ const ChakraShowcases = () => {
</HStack> </HStack>
</section> </section>
<section>
<Heading textStyle="heading.md" mb={ 2 }>Tooltips</Heading>
<HStack gap={ 4 }>
<Tooltip content="Tooltip content">
<span>Default</span>
</Tooltip>
<Tooltip content="Tooltip content" visual="navigation">
<span>Navigation</span>
</Tooltip>
</HStack>
</section>
<section> <section>
<Heading textStyle="heading.md" mb={ 2 }>Progress Circle</Heading> <Heading textStyle="heading.md" mb={ 2 }>Progress Circle</Heading>
<HStack gap={ 4 }> <HStack gap={ 4 }>
......
...@@ -11,7 +11,7 @@ type Props = { ...@@ -11,7 +11,7 @@ type Props = {
const GasUsedToTargetRatio = ({ value, isLoading }: Props) => { const GasUsedToTargetRatio = ({ value, isLoading }: Props) => {
return ( return (
<Tooltip content="% of Gas Target"> <Tooltip content="% of Gas Target">
<Skeleton color="text_secondary" loading={ isLoading }> <Skeleton color="text.secondary" loading={ isLoading }>
<span>{ (value > 0 ? '+' : '') + value.toLocaleString(undefined, { maximumFractionDigits: 2 }) }%</span> <span>{ (value > 0 ? '+' : '') + value.toLocaleString(undefined, { maximumFractionDigits: 2 }) }%</span>
</Skeleton> </Skeleton>
</Tooltip> </Tooltip>
......
import { Link, Text, chakra, Table } from '@chakra-ui/react'; import { Text, chakra } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import { Alert } from 'toolkit/chakra/alert'; import { Alert } from 'toolkit/chakra/alert';
import { Link } from 'toolkit/chakra/link';
import { Skeleton } from 'toolkit/chakra/skeleton'; import { Skeleton } from 'toolkit/chakra/skeleton';
import { TableCell, TableRow } from 'toolkit/chakra/table';
interface InjectedProps { interface InjectedProps {
content: React.ReactNode; content: React.ReactNode;
...@@ -56,7 +58,7 @@ const SocketNewItemsNotice = chakra(({ children, className, url, num, alert, typ ...@@ -56,7 +58,7 @@ const SocketNewItemsNotice = chakra(({ children, className, url, num, alert, typ
const content = !isLoading ? ( const content = !isLoading ? (
<Alert <Alert
className={ className } className={ className }
visual="warning_table" status="warning_table"
px={ 4 } px={ 4 }
py="6px" py="6px"
fontSize="sm" fontSize="sm"
...@@ -82,7 +84,7 @@ export const Desktop = ({ ...props }: Props) => { ...@@ -82,7 +84,7 @@ export const Desktop = ({ ...props }: Props) => {
my={ props.isLoading ? '6px' : 0 } my={ props.isLoading ? '6px' : 0 }
{ ...props } { ...props }
> >
{ ({ content }) => <Table.Row><Table.Cell colSpan={ 100 } p={ 0 } _first={{ p: 0 }} _last={{ p: 0 }}>{ content }</Table.Cell></Table.Row> } { ({ content }) => <TableRow><TableCell colSpan={ 100 } p={ 0 } _first={{ p: 0 }} _last={{ p: 0 }}>{ content }</TableCell></TableRow> }
</SocketNewItemsNotice> </SocketNewItemsNotice>
); );
}; };
......
import { Box, Flex, chakra } from '@chakra-ui/react'; import type { HTMLChakraProps } from '@chakra-ui/react';
import { Box, Flex } from '@chakra-ui/react';
import { clamp } from 'es-toolkit'; import { clamp } from 'es-toolkit';
import React from 'react'; import React from 'react';
import { Skeleton } from 'toolkit/chakra/skeleton'; import { Skeleton } from 'toolkit/chakra/skeleton';
interface Props { interface Props extends Omit<HTMLChakraProps<'div'>, 'direction'> {
className?: string;
value: number; value: number;
colorScheme?: 'green' | 'gray'; colorScheme?: 'green' | 'gray';
isLoading?: boolean; isLoading?: boolean;
...@@ -13,13 +13,13 @@ interface Props { ...@@ -13,13 +13,13 @@ interface Props {
const WIDTH = 50; const WIDTH = 50;
const Utilization = ({ className, value, colorScheme = 'green', isLoading }: Props) => { const Utilization = ({ value, colorScheme = 'green', isLoading, ...rest }: Props) => {
const valueString = (clamp(value * 100 || 0, 0, 100)).toLocaleString(undefined, { maximumFractionDigits: 2 }) + '%'; const valueString = (clamp(value * 100 || 0, 0, 100)).toLocaleString(undefined, { maximumFractionDigits: 2 }) + '%';
const colorGrayScheme = { _light: 'gray.500', _dark: 'gray.400' }; const colorGrayScheme = { _light: 'gray.500', _dark: 'gray.400' };
const color = colorScheme === 'gray' ? colorGrayScheme : 'green.500'; const color = colorScheme === 'gray' ? colorGrayScheme : 'green.500';
return ( return (
<Flex className={ className } alignItems="center" columnGap={ 2 }> <Flex alignItems="center" columnGap={ 2 } { ...rest }>
<Skeleton loading={ isLoading } w={ `${ WIDTH }px` } h="4px" borderRadius="full" overflow="hidden"> <Skeleton loading={ isLoading } w={ `${ WIDTH }px` } h="4px" borderRadius="full" overflow="hidden">
<Box bg={{ _light: 'blackAlpha.200', _dark: 'whiteAlpha.200' }} h="100%"> <Box bg={{ _light: 'blackAlpha.200', _dark: 'whiteAlpha.200' }} h="100%">
<Box bg={ color } w={ valueString } h="100%"/> <Box bg={ color } w={ valueString } h="100%"/>
...@@ -34,4 +34,4 @@ const Utilization = ({ className, value, colorScheme = 'green', isLoading }: Pro ...@@ -34,4 +34,4 @@ const Utilization = ({ className, value, colorScheme = 'green', isLoading }: Pro
); );
}; };
export default React.memo(chakra(Utilization)); export default React.memo(Utilization);
import { chakra, Box } from '@chakra-ui/react'; import { chakra } from '@chakra-ui/react';
import BigNumber from 'bignumber.js'; import BigNumber from 'bignumber.js';
import React from 'react'; import React from 'react';
...@@ -31,14 +31,12 @@ const BlockGasUsed = ({ className, gasUsed, gasLimit, gasTarget, isLoading }: Pr ...@@ -31,14 +31,12 @@ const BlockGasUsed = ({ className, gasUsed, gasLimit, gasTarget, isLoading }: Pr
return ( return (
<> <>
<Tooltip content="Gas Used %" disabled={ isLoading }> <Tooltip content="Gas Used %" disabled={ isLoading }>
<Box> <Utilization
<Utilization colorScheme="gray"
colorScheme="gray" value={ BigNumber(gasUsed).dividedBy(BigNumber(gasLimit)).toNumber() }
value={ BigNumber(gasUsed).dividedBy(BigNumber(gasLimit)).toNumber() } isLoading={ isLoading }
isLoading={ isLoading } className={ className }
className={ className } />
/>
</Box>
</Tooltip> </Tooltip>
{ gasTarget && ( { gasTarget && (
<> <>
......
...@@ -78,7 +78,7 @@ const Icon = (props: IconProps) => { ...@@ -78,7 +78,7 @@ const Icon = (props: IconProps) => {
return ( return (
<Tooltip <Tooltip
content={ content } content={ content }
visual="popover" variant="popover"
positioning={{ positioning={{
placement: 'bottom-start', placement: 'bottom-start',
}} }}
......
import React from 'react';
import { Tooltip } from 'toolkit/chakra/tooltip';
import Utilization from 'ui/shared/Utilization/Utilization';
import { Section, Container, SectionHeader, SamplesStack, Sample } from './parts';
const TooltipsShowcase = () => {
return (
<Container value="tooltips">
<Section>
<SectionHeader>Variant</SectionHeader>
<SamplesStack>
<Sample label="variant: regular">
<Tooltip content="Tooltip content">
<span>Default</span>
</Tooltip>
<Tooltip content="Tooltip content">
<Utilization value={ 0.5 }/>
</Tooltip>
</Sample>
<Sample label="variant: navigation">
<Tooltip content="Tooltip content" variant="navigation">
<span>Default</span>
</Tooltip>
</Sample>
<Sample label="variant: popover">
<Tooltip content="Tooltip content" variant="popover">
<span>Default</span>
</Tooltip>
</Sample>
</SamplesStack>
</Section>
</Container>
);
};
export default React.memo(TooltipsShowcase);
...@@ -10,7 +10,7 @@ const MaintenanceAlert = () => { ...@@ -10,7 +10,7 @@ const MaintenanceAlert = () => {
} }
return ( return (
<Alert visual="neutral"> <Alert status="neutral">
<Box <Box
dangerouslySetInnerHTML={{ __html: config.UI.maintenanceAlert.message }} dangerouslySetInnerHTML={{ __html: config.UI.maintenanceAlert.message }}
css={{ css={{
......
...@@ -48,7 +48,7 @@ const NavLinkGroup = ({ item }: Props) => { ...@@ -48,7 +48,7 @@ const NavLinkGroup = ({ item }: Props) => {
return ( return (
<Tooltip <Tooltip
visual="popover" variant="popover"
content={ content } content={ content }
onOpenChange={ onOpenChange } onOpenChange={ onOpenChange }
lazyMount={ false } lazyMount={ false }
......
...@@ -59,7 +59,7 @@ const NavLink = ({ item, onClick, isCollapsed, isDisabled }: Props) => { ...@@ -59,7 +59,7 @@ const NavLink = ({ item, onClick, isCollapsed, isDisabled }: Props) => {
showArrow={ false } showArrow={ false }
disabled={ isMobile || isCollapsed === false || (isCollapsed === undefined && isXLScreen) } disabled={ isMobile || isCollapsed === false || (isCollapsed === undefined && isXLScreen) }
positioning={{ placement: 'right', offset: { crossAxis: 0, mainAxis: 20 } }} positioning={{ placement: 'right', offset: { crossAxis: 0, mainAxis: 20 } }}
visual="navigation" variant="navigation"
contentProps={{ contentProps={{
color: isInternalLink && item.isActive ? 'link.navigation.fg.selected' : 'link.navigation.fg.hover', color: isInternalLink && item.isActive ? 'link.navigation.fg.selected' : 'link.navigation.fg.hover',
}} }}
......
...@@ -58,7 +58,7 @@ const NavLinkGroup = ({ item, isCollapsed }: Props) => { ...@@ -58,7 +58,7 @@ const NavLinkGroup = ({ item, isCollapsed }: Props) => {
positioning={{ placement: 'right-start', offset: { crossAxis: 0, mainAxis: 8 } }} positioning={{ placement: 'right-start', offset: { crossAxis: 0, mainAxis: 8 } }}
// should not be lazy to help google indexing pages // should not be lazy to help google indexing pages
lazyMount={ false } lazyMount={ false }
visual="popover" variant="popover"
interactive interactive
> >
<Box <Box
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment