import React, { type FC, useState } from 'react'; import { Box, Center, Heading, CloseButton, Collapse } from '@chakra-ui/react'; import useThemeConfig from '../../hooks/useThemeConfig'; import { ANNOUNCEMENT } from '../../constant/storage'; export type AnnouncementBarConfig = { /** * @description whether announce closeable */ isCloseable?: boolean; /** * @description announce text color */ textColor?: string; /** * @description announce background color */ backgroundColor?: string; /** * @description announce dom id */ id: string; /** * @description announce content, like html string */ content: string; }; const AnnouncementBar: FC = () => { const [showAnnounce, setAnnounce] = useState( !Number(localStorage.getItem(ANNOUNCEMENT)) ); const { announcementBar } = useThemeConfig(); if (!announcementBar) return null; const { content, id, isCloseable, textColor = 'brand.500', backgroundColor } = announcementBar; return (
{isCloseable && ( { localStorage.setItem(ANNOUNCEMENT, '1'); setAnnounce(false); }} /> )}
); }; export default AnnouncementBar;