Commit bfc01d4f authored by tom's avatar tom

smooth scroll when expanding cut

parent 64a9fb0b
import { Grid, GridItem, Text, Box, Icon, Link, Tag, Flex } from '@chakra-ui/react'; import { Grid, GridItem, Text, Box, Icon, Link, Tag, Flex } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import { scroller, Element } from 'react-scroll';
import { tx } from 'data/tx'; import { tx } from 'data/tx';
import clockIcon from 'icons/clock.svg'; import clockIcon from 'icons/clock.svg';
...@@ -30,6 +31,10 @@ const TxDetails = () => { ...@@ -30,6 +31,10 @@ const TxDetails = () => {
const handleCutClick = React.useCallback(() => { const handleCutClick = React.useCallback(() => {
setIsExpanded((flag) => !flag); setIsExpanded((flag) => !flag);
scroller.scrollTo('TxDetails__cutLink', {
duration: 500,
smooth: true,
});
}, []); }, []);
return ( return (
...@@ -150,16 +155,18 @@ const TxDetails = () => { ...@@ -150,16 +155,18 @@ const TxDetails = () => {
<Text variant="secondary" ml={ 1 }>(${ tx.burnt_fees.value_usd.toFixed(2) })</Text> <Text variant="secondary" ml={ 1 }>(${ tx.burnt_fees.value_usd.toFixed(2) })</Text>
</DetailsInfoItem> </DetailsInfoItem>
<GridItem colSpan={ 2 }> <GridItem colSpan={ 2 }>
<Link <Element name="TxDetails__cutLink">
mt={ 6 } <Link
display="inline-block" mt={ 6 }
fontSize="sm" display="inline-block"
textDecorationLine="underline" fontSize="sm"
textDecorationStyle="dashed" textDecorationLine="underline"
onClick={ handleCutClick } textDecorationStyle="dashed"
> onClick={ handleCutClick }
{ isExpanded ? 'Hide details' : 'View details' } >
</Link> { isExpanded ? 'Hide details' : 'View details' }
</Link>
</Element>
</GridItem> </GridItem>
{ isExpanded && ( { isExpanded && (
<> <>
......
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