import { useMemo } from 'react'; import { Button, Menu, MenuButton, MenuList } from '@chakra-ui/react'; import { Markdown } from '~/components'; import { useColorValue, useBreakpointValue, useConfig } from '~/context'; import { useOpposingColor, useStrf } from '~/hooks'; import type { IConfig } from '~/types'; import type { TFooterButton } from './types'; /** * Filter the configuration object based on values that are strings for formatting. */ function getConfigFmt(config: IConfig): Record { const fmt = {} as Record; for (const [k, v] of Object.entries(config)) { if (typeof v === 'string') { fmt[k] = v; } } return fmt; } export const FooterButton: React.FC = (props: TFooterButton) => { const { content, title, side, ...rest } = props; const config = useConfig(); const strF = useStrf(); const fmt = useMemo(() => getConfigFmt(config), [config]); const fmtContent = useMemo(() => strF(content, fmt), [fmt, content, strF]); const placement = side === 'left' ? 'top' : side === 'right' ? 'top-end' : undefined; const bg = useColorValue('white', 'gray.900'); const color = useOpposingColor(bg); const size = useBreakpointValue({ base: 'xs', lg: 'sm' }); return ( {title} ); };