Commit f02904c3 authored by tom's avatar tom

fix margin of action bar

parent 473d2b27
...@@ -61,37 +61,48 @@ const BlocksContent = ({ type }: Props) => { ...@@ -61,37 +61,48 @@ const BlocksContent = ({ type }: Props) => {
handler: handleNewBlockMessage, handler: handleNewBlockMessage,
}); });
if (isLoading) { const content = (() => {
if (isLoading) {
return (
<>
<Show below="lg" key="skeleton-mobile">
<BlocksSkeletonMobile/>
</Show>
<Show above="lg" key="skeleton-desktop">
<SkeletonTable columns={ [ '125px', '120px', '21%', '64px', '35%', '22%', '22%' ] }/>
</Show>
</>
);
}
if (isError) {
return <DataFetchAlert/>;
}
if (data.items.length === 0) {
return <Alert>There are no blocks.</Alert>;
}
return ( return (
<> <>
<Show below="lg" key="skeleton-mobile"> { socketAlert && <Alert status="warning" mb={ 6 } as="a" href={ window.document.location.href }>{ socketAlert }</Alert> }
<BlocksSkeletonMobile/> <Show below="lg" key="content-mobile"><BlocksList data={ data.items }/></Show>
</Show> <Show above="lg" key="content-desktop"><BlocksTable data={ data.items }/></Show>
<Show above="lg" key="skeleton-desktop">
<Skeleton h={ 6 } mb={ 8 } w="150px"/>
<SkeletonTable columns={ [ '125px', '120px', '21%', '64px', '35%', '22%', '22%' ] }/>
</Show>
</> </>
); );
}
if (isError) { })();
return <DataFetchAlert/>;
}
if (data.items.length === 0) {
return <Alert>There are no blocks.</Alert>;
}
return ( return (
<> <>
<Text as="span">Total of { data.items[0].height.toLocaleString() } blocks</Text> { data ?
<Text mb={{ base: 0, lg: 6 }}>Total of { data.items[0].height.toLocaleString() } blocks</Text> :
<Skeleton h="24px" w="200px" mb={{ base: 0, lg: 6 }}/>
}
<ActionBar> <ActionBar>
<Pagination ml="auto" { ...pagination }/> <Pagination ml="auto" { ...pagination }/>
</ActionBar> </ActionBar>
{ socketAlert && <Alert status="warning" mt={ 8 } as="a" href={ window.document.location.href }>{ socketAlert }</Alert> } { content }
<Show below="lg" key="content-mobile"><BlocksList data={ data.items }/></Show>
<Show above="lg" key="content-desktop"><BlocksTable data={ data.items }/></Show>
</> </>
); );
}; };
......
...@@ -12,7 +12,7 @@ interface Props { ...@@ -12,7 +12,7 @@ interface Props {
const BlocksList = ({ data }: Props) => { const BlocksList = ({ data }: Props) => {
return ( return (
<Box mt={ 8 }> <Box>
<AnimatePresence initial={ false }> <AnimatePresence initial={ false }>
{ /* TODO prop "enableTimeIncrement" should be set to false for second and later pages */ } { /* TODO prop "enableTimeIncrement" should be set to false for second and later pages */ }
{ data.map((item) => <BlocksListItem key={ item.height } data={ item } enableTimeIncrement/>) } { data.map((item) => <BlocksListItem key={ item.height } data={ item } enableTimeIncrement/>) }
......
...@@ -17,7 +17,7 @@ interface Props { ...@@ -17,7 +17,7 @@ interface Props {
const BlocksTable = ({ data }: Props) => { const BlocksTable = ({ data }: Props) => {
return ( return (
<Table variant="simple" minWidth="1040px" size="md" fontWeight={ 500 } mt={ 8 }> <Table variant="simple" minWidth="1040px" size="md" fontWeight={ 500 }>
<Thead top={ 80 }> <Thead top={ 80 }>
<Tr> <Tr>
<Th width="125px">Block</Th> <Th width="125px">Block</Th>
......
...@@ -24,9 +24,7 @@ const BlockPageContent = () => { ...@@ -24,9 +24,7 @@ const BlockPageContent = () => {
return ( return (
<Page> <Page>
<PageTitle text={ `Block #${ router.query.id }` }/> <PageTitle text={ `Block #${ router.query.id }` }/>
<RoutedTabs <RoutedTabs tabs={ TABS } tabListMarginBottom={{ base: 6, lg: 12 }}/>
tabs={ TABS }
/>
</Page> </Page>
); );
}; };
......
...@@ -17,9 +17,7 @@ const BlocksPageContent = () => { ...@@ -17,9 +17,7 @@ const BlocksPageContent = () => {
return ( return (
<Page> <Page>
<PageTitle text="Blocks"/> <PageTitle text="Blocks"/>
<RoutedTabs <RoutedTabs tabs={ TABS } tabListMarginBottom={{ base: 6, lg: 8 }}/>
tabs={ TABS }
/>
</Page> </Page>
); );
}; };
......
...@@ -17,7 +17,7 @@ const PrivateTags = () => { ...@@ -17,7 +17,7 @@ const PrivateTags = () => {
return ( return (
<Page> <Page>
<PageTitle text="Private tags"/> <PageTitle text="Private tags"/>
<RoutedTabs tabs={ TABS }/> <RoutedTabs tabs={ TABS } tabListMarginBottom={{ base: 6, lg: 8 }}/>
</Page> </Page>
); );
}; };
......
...@@ -75,9 +75,7 @@ const TransactionPageContent = () => { ...@@ -75,9 +75,7 @@ const TransactionPageContent = () => {
</Flex> </Flex>
) } ) }
</Flex> </Flex>
<RoutedTabs <RoutedTabs tabs={ TABS } tabListMarginBottom={{ base: 6, lg: 12 }}/>
tabs={ TABS }
/>
</Page> </Page>
); );
}; };
......
...@@ -22,7 +22,7 @@ const Transactions = () => { ...@@ -22,7 +22,7 @@ const Transactions = () => {
<Page hideMobileHeaderOnScrollDown> <Page hideMobileHeaderOnScrollDown>
<Box h="100%"> <Box h="100%">
<PageTitle text="Transactions"/> <PageTitle text="Transactions"/>
<RoutedTabs tabs={ TABS }/> <RoutedTabs tabs={ TABS } tabListMarginBottom={{ base: 6, lg: 8 }}/>
</Box> </Box>
</Page> </Page>
); );
......
import { Flex, useColorModeValue } from '@chakra-ui/react'; import { Flex, useColorModeValue, chakra } from '@chakra-ui/react';
import throttle from 'lodash/throttle'; import throttle from 'lodash/throttle';
import React from 'react'; import React from 'react';
...@@ -6,12 +6,13 @@ import ScrollDirectionContext from 'ui/ScrollDirectionContext'; ...@@ -6,12 +6,13 @@ import ScrollDirectionContext from 'ui/ScrollDirectionContext';
type Props = { type Props = {
children: React.ReactNode; children: React.ReactNode;
className?: string;
} }
const TOP_UP = 106; const TOP_UP = 106;
const TOP_DOWN = 0; const TOP_DOWN = 0;
const ActionBar = ({ children }: Props) => { const ActionBar = ({ children, className }: Props) => {
const [ isSticky, setIsSticky ] = React.useState(false); const [ isSticky, setIsSticky ] = React.useState(false);
const ref = React.useRef<HTMLDivElement>(null); const ref = React.useRef<HTMLDivElement>(null);
...@@ -43,17 +44,16 @@ const ActionBar = ({ children }: Props) => { ...@@ -43,17 +44,16 @@ const ActionBar = ({ children }: Props) => {
<ScrollDirectionContext.Consumer> <ScrollDirectionContext.Consumer>
{ (scrollDirection) => ( { (scrollDirection) => (
<Flex <Flex
className={ className }
backgroundColor={ bgColor } backgroundColor={ bgColor }
// mt={ -6 } py={ 6 }
pt={ 6 }
pb={ 6 }
mx={{ base: -4, lg: 0 }} mx={{ base: -4, lg: 0 }}
px={{ base: 4, lg: 0 }} px={{ base: 4, lg: 0 }}
justifyContent="space-between" justifyContent="space-between"
width={{ base: '100vw', lg: 'unset' }} width={{ base: '100vw', lg: 'unset' }}
position="sticky" position="sticky"
top={{ base: scrollDirection === 'down' ? `${ TOP_DOWN }px` : `${ TOP_UP }px`, lg: 0 }} top={{ base: scrollDirection === 'down' ? `${ TOP_DOWN }px` : `${ TOP_UP }px`, lg: 0 }}
transitionProperty="top,box-shadow" transitionProperty="top,box-shadow,background-color,color"
transitionDuration="slow" transitionDuration="slow"
zIndex={{ base: 'sticky2', lg: 'docked' }} zIndex={{ base: 'sticky2', lg: 'docked' }}
boxShadow={{ base: isSticky ? 'md' : 'none', lg: 'none' }} boxShadow={{ base: isSticky ? 'md' : 'none', lg: 'none' }}
...@@ -66,4 +66,4 @@ const ActionBar = ({ children }: Props) => { ...@@ -66,4 +66,4 @@ const ActionBar = ({ children }: Props) => {
); );
}; };
export default ActionBar; export default chakra(ActionBar);
import type { ChakraProps } from '@chakra-ui/react';
import { import {
Tab, Tab,
Tabs, Tabs,
...@@ -25,9 +26,10 @@ const hiddenItemStyles: StyleProps = { ...@@ -25,9 +26,10 @@ const hiddenItemStyles: StyleProps = {
interface Props { interface Props {
tabs: Array<RoutedTab>; tabs: Array<RoutedTab>;
tabListMarginBottom?: ChakraProps['marginBottom'];
} }
const RoutedTabs = ({ tabs }: Props) => { const RoutedTabs = ({ tabs, tabListMarginBottom }: Props) => {
const router = useRouter(); const router = useRouter();
const [ activeTabIndex, setActiveTabIndex ] = useState<number>(tabs.length + 1); const [ activeTabIndex, setActiveTabIndex ] = useState<number>(tabs.length + 1);
useEffect(() => { useEffect(() => {
...@@ -59,7 +61,7 @@ const RoutedTabs = ({ tabs }: Props) => { ...@@ -59,7 +61,7 @@ const RoutedTabs = ({ tabs }: Props) => {
return ( return (
<Tabs variant="soft-rounded" colorScheme="blue" isLazy onChange={ handleTabChange } index={ activeTabIndex }> <Tabs variant="soft-rounded" colorScheme="blue" isLazy onChange={ handleTabChange } index={ activeTabIndex }>
<TabList <TabList
marginBottom={{ base: 6, lg: 12 }} marginBottom={ tabListMarginBottom }
flexWrap="nowrap" flexWrap="nowrap"
whiteSpace="nowrap" whiteSpace="nowrap"
ref={ listRef } ref={ listRef }
......
...@@ -65,31 +65,33 @@ const TxsContent = ({ ...@@ -65,31 +65,33 @@ const TxsContent = ({
} = useQueryWithPages<TransactionsResponse>(apiPath, queryName, stateFilter && { filter: stateFilter }); } = useQueryWithPages<TransactionsResponse>(apiPath, queryName, stateFilter && { filter: stateFilter });
// } = useQueryWithPages({ ...filters, filter: stateFilter, apiPath }); // } = useQueryWithPages({ ...filters, filter: stateFilter, apiPath });
if (isError) { const content = (() => {
return <DataFetchAlert/>; if (isError) {
} return <DataFetchAlert/>;
}
const txs = data?.items; const txs = data?.items;
if (!isLoading && !txs) { if (!isLoading && !txs?.length) {
return <Alert>There are no transactions.</Alert>; return <Alert>There are no transactions.</Alert>;
} }
let content = ( if (!isLoading && txs) {
<> return <TxsWithSort txs={ txs } sorting={ sorting } sort={ sort }/>;
<Show below="lg" ssr={ false }><TxsSkeletonMobile/></Show> }
<Show above="lg" ssr={ false }><TxsSkeletonDesktop/></Show>
</>
);
if (!isLoading && txs) { return (
content = <TxsWithSort txs={ txs } sorting={ sorting } sort={ sort }/>; <>
} <Show below="lg" ssr={ false }><TxsSkeletonMobile/></Show>
<Show above="lg" ssr={ false }><TxsSkeletonDesktop/></Show>
</>
);
})();
return ( return (
<> <>
{ showDescription && <Box mb={ 12 }>Only the first 10,000 elements are displayed</Box> } { showDescription && <Box mb={{ base: 6, lg: 12 }}>Only the first 10,000 elements are displayed</Box> }
<TxsHeader sorting={ sorting } setSorting={ setSorting } paginationProps={ pagination }/> <TxsHeader mt={ -6 } sorting={ sorting } setSorting={ setSorting } paginationProps={ pagination }/>
{ content } { content }
</> </>
); );
......
import { HStack } from '@chakra-ui/react'; import { HStack, chakra } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import type { Sort } from 'types/client/txs-sort'; import type { Sort } from 'types/client/txs-sort';
...@@ -16,13 +16,14 @@ type Props = { ...@@ -16,13 +16,14 @@ type Props = {
sorting: Sort; sorting: Sort;
setSorting: (val: Sort | ((val: Sort) => Sort)) => void; setSorting: (val: Sort | ((val: Sort) => Sort)) => void;
paginationProps: PaginationProps; paginationProps: PaginationProps;
className?: string;
} }
const TxsHeader = ({ sorting, setSorting, paginationProps }: Props) => { const TxsHeader = ({ sorting, setSorting, paginationProps, className }: Props) => {
const isMobile = useIsMobile(false); const isMobile = useIsMobile(false);
return ( return (
<ActionBar> <ActionBar className={ className }>
<HStack> <HStack>
{ /* api is not implemented */ } { /* api is not implemented */ }
{ /* <TxsFilters { /* <TxsFilters
...@@ -51,4 +52,4 @@ const TxsHeader = ({ sorting, setSorting, paginationProps }: Props) => { ...@@ -51,4 +52,4 @@ const TxsHeader = ({ sorting, setSorting, paginationProps }: Props) => {
); );
}; };
export default TxsHeader; export default chakra(TxsHeader);
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