1
0
Fork 1
mirror of https://github.com/thatmattlove/hyperglass.git synced 2026-04-18 22:08:27 +00:00
thatmattlove-hyperglass/hyperglass/ui/components/Footer/button.tsx
2020-12-29 02:07:42 -07:00

37 lines
1.1 KiB
TypeScript

import { Button, Menu, MenuButton, MenuList } from '@chakra-ui/react';
import { Markdown } from '~/components';
import { useColorValue, useBreakpointValue } from '~/context';
import { useOpposingColor } from '~/hooks';
import type { TFooterButton } from './types';
export const FooterButton = (props: TFooterButton) => {
const { content, title, side, ...rest } = props;
const placement = side === 'left' ? 'top' : side === 'right' ? 'top-start' : undefined;
const bg = useColorValue('white', 'gray.900');
const color = useOpposingColor(bg);
const size = useBreakpointValue({ base: 'xs', lg: 'sm' });
return (
<Menu placement={placement}>
<MenuButton
as={Button}
size={size}
variant="ghost"
aria-label={typeof title === 'string' ? title : undefined}>
{title}
</MenuButton>
<MenuList
bg={bg}
boxShadow="2xl"
color={color}
px={6}
py={4}
textAlign="left"
mx={{ base: 1, lg: 2 }}
maxW={{ base: '100vw', lg: '50vw' }}
{...rest}>
<Markdown content={content} />
</MenuList>
</Menu>
);
};