1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00
Files
checktheroads-hyperglass/hyperglass/ui/components/footer/footer.tsx

68 lines
2.2 KiB
TypeScript
Raw Normal View History

2021-01-01 11:32:35 -07:00
import dynamic from 'next/dynamic';
import { Button, Flex, Link, Icon, HStack, useToken } from '@chakra-ui/react';
import { If } from '~/components';
import { useConfig, useMobile, useColorValue, useBreakpointValue } from '~/context';
import { useStrf } from '~/hooks';
import { FooterButton } from './button';
import { ColorModeToggle } from './colorMode';
const CodeIcon = dynamic<MeronexIcon>(() => import('@meronex/icons/fi').then(i => i.FiCode));
const ExtIcon = dynamic<MeronexIcon>(() => import('@meronex/icons/go').then(i => i.GoLinkExternal));
2021-01-03 23:51:09 -07:00
export const Footer: React.FC = () => {
2021-01-01 11:32:35 -07:00
const { web, content, primary_asn } = useConfig();
const footerBg = useColorValue('blackAlpha.50', 'whiteAlpha.100');
const footerColor = useColorValue('black', 'white');
const extUrl = useStrf(web.external_link.url, { primary_asn }) ?? '/';
const size = useBreakpointValue({ base: useToken('sizes', 4), lg: useToken('sizes', 6) });
const btnSize = useBreakpointValue({ base: 'xs', lg: 'sm' });
const isMobile = useMobile();
return (
<HStack
px={6}
py={4}
w="100%"
zIndex={1}
as="footer"
bg={footerBg}
color={footerColor}
spacing={{ base: 8, lg: 6 }}
2021-01-03 23:51:09 -07:00
justifyContent={{ base: 'center', lg: 'space-between' }}
>
2021-01-01 11:32:35 -07:00
<If c={web.terms.enable}>
<FooterButton side="left" content={content.terms} title={web.terms.title} />
</If>
<If c={web.help_menu.enable}>
<FooterButton side="left" content={content.help_menu} title={web.help_menu.title} />
</If>
<If c={web.external_link.enable}>
<Button
as={Link}
isExternal
href={extUrl}
size={btnSize}
variant="ghost"
rightIcon={<ExtIcon />}
2021-01-03 23:51:09 -07:00
aria-label={web.external_link.title}
>
2021-01-01 11:32:35 -07:00
{web.external_link.title}
</Button>
</If>
2021-04-22 21:45:01 -07:00
{!isMobile && <Flex p={0} flex="1 0 auto" maxWidth="100%" mr="auto" />}
2021-01-01 11:32:35 -07:00
<If c={web.credit.enable}>
<FooterButton
side="right"
content={content.credit}
title={<Icon as={CodeIcon} boxSize={size} />}
/>
</If>
<ColorModeToggle size={size} />
</HStack>
);
};