Skip to content

Commit 4033b02

Browse files
committed
feat: added dismiss button
1 parent 756c66e commit 4033b02

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

components/Banner.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
import { Center, Flex, Text, chakra } from '@chakra-ui/react'
2+
import { CloseIcon } from '@chakra-ui/icons'
23

34
const Banner = () => {
5+
const dismissBanner = () => {
6+
localStorage.setItem('bannerDismissed', 'true')
7+
const banner = document.getElementById('banner')
8+
if (banner) {
9+
banner.style.display = 'none'
10+
}
11+
}
12+
413
return (
514
<Center
615
py="2"
716
px="3"
817
bgGradient="linear(to-r,cyan.700, purple.500)"
918
color="white"
1019
textAlign="center"
20+
id="banner"
1121
>
1222
<Flex align="center" fontSize="sm">
1323
<Text fontWeight="medium" maxW={{ base: '32ch', md: 'unset' }}>
@@ -28,6 +38,17 @@ const Banner = () => {
2838
>
2939
Subscribe now!{' '}
3040
</chakra.a>
41+
<chakra.button
42+
onClick={dismissBanner}
43+
ms="6"
44+
color="whiteAlpha.900"
45+
fontWeight="semibold"
46+
px="3"
47+
py="1"
48+
rounded="base"
49+
>
50+
<CloseIcon />
51+
</chakra.button>
3152
</Flex>
3253
</Center>
3354
)

0 commit comments

Comments
 (0)