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/button.tsx

40 lines
1.2 KiB
TypeScript
Raw Normal View History

2021-01-03 23:51:09 -07:00
import { Button, Menu, MenuButton, MenuList } from '@chakra-ui/react';
2021-01-01 11:32:35 -07:00
import { Markdown } from '~/components';
import { useColorValue, useBreakpointValue } from '~/context';
import { useOpposingColor } from '~/hooks';
import type { TFooterButton } from './types';
2021-01-03 23:51:09 -07:00
export const FooterButton: React.FC<TFooterButton> = (props: TFooterButton) => {
2021-01-01 11:32:35 -07:00
const { content, title, side, ...rest } = props;
2021-01-02 12:53:31 -07:00
const placement = side === 'left' ? 'top' : side === 'right' ? 'top-end' : undefined;
2021-01-01 11:32:35 -07:00
const bg = useColorValue('white', 'gray.900');
const color = useOpposingColor(bg);
const size = useBreakpointValue({ base: 'xs', lg: 'sm' });
return (
2021-01-02 12:53:31 -07:00
<Menu placement={placement} preventOverflow isLazy>
2021-01-01 11:32:35 -07:00
<MenuButton
as={Button}
size={size}
variant="ghost"
2021-01-03 23:51:09 -07:00
aria-label={typeof title === 'string' ? title : undefined}
>
2021-01-01 11:32:35 -07:00
{title}
</MenuButton>
<MenuList
px={6}
py={4}
2021-01-02 12:53:31 -07:00
bg={bg}
color={color}
boxShadow="2xl"
2021-01-01 11:32:35 -07:00
textAlign="left"
mx={{ base: 1, lg: 2 }}
2021-01-02 12:53:31 -07:00
maxW={{ base: '100%', lg: '50vw' }}
2021-01-03 23:51:09 -07:00
{...rest}
>
2021-01-01 11:32:35 -07:00
<Markdown content={content} />
</MenuList>
</Menu>
);
};