Skip to content

Commit 4a273e8

Browse files
committed
feat: migrate BannerNotification to tw
including `DismissableBnner`
1 parent 065a055 commit 4a273e8

File tree

3 files changed

+20
-42
lines changed

3 files changed

+20
-42
lines changed

src/components/Banners/BannerNotification.tsx

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,20 @@
1-
import React from "react"
2-
import { Center, FlexProps, useMediaQuery } from "@chakra-ui/react"
3-
4-
import { lightTheme as oldTheme } from "../../theme"
5-
6-
export type BannerNotificationProps = FlexProps & {
1+
export type BannerNotificationProps = React.HTMLAttributes<HTMLDivElement> & {
72
shouldShow?: boolean
83
}
94

105
const BannerNotification = ({
116
children,
12-
shouldShow = false,
7+
shouldShow,
138
...props
149
}: BannerNotificationProps) => {
15-
const [isLGScreen] = useMediaQuery(`min-width: ${oldTheme.breakpoints.l}`)
10+
if (!shouldShow) return <></>
1611
return (
17-
<>
18-
{shouldShow && (
19-
<Center
20-
as="aside"
21-
maxW={isLGScreen ? oldTheme.variables.maxPageWidth : "100%"}
22-
w="100%"
23-
py="4"
24-
px="8"
25-
bg="primary.base"
26-
color="background.base"
27-
sx={{
28-
a: {
29-
color: "background.base",
30-
},
31-
}}
32-
{...props}
33-
>
34-
{children}
35-
</Center>
36-
)}
37-
</>
12+
<aside
13+
className="flex items-center justify-center gap-2 bg-primary-action px-8 py-4 text-white [&_a]:text-white [&_a]:hover:text-white/80"
14+
{...props}
15+
>
16+
{children}
17+
</aside>
3818
)
3919
}
4020

src/components/Banners/DismissableBanner/index.tsx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// Libraries
2-
import React, { useEffect, useState } from "react"
3-
import { Center, CloseButton } from "@chakra-ui/react"
1+
import { useEffect, useState } from "react"
2+
import { MdClose } from "react-icons/md"
3+
4+
import { Button } from "@/components/ui/buttons/Button"
5+
import { Center } from "@/components/ui/flex"
46

5-
// Components
67
import BannerNotification from "../BannerNotification"
78

8-
// Interface
99
export type DismissableBannerProps = {
1010
children: JSX.Element
1111
storageKey: string
@@ -28,13 +28,11 @@ const DismissableBanner = ({
2828
}
2929

3030
return (
31-
<BannerNotification shouldShow={show} gap="8">
32-
<Center marginInlineStart="auto">{children}</Center>
33-
<CloseButton
34-
marginInlineStart="auto"
35-
onClick={onClose}
36-
aria-label="Close Banner"
37-
/>
31+
<BannerNotification shouldShow={show} className="gap-8">
32+
<Center className="ms-auto">{children}</Center>
33+
<Button className="ms-auto" onClick={onClose} aria-label="Close Banner">
34+
<MdClose />
35+
</Button>
3836
</BannerNotification>
3937
)
4038
}

src/layouts/UseCases.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export const UseCasesLayout = ({
177177
width="full"
178178
dir={contentNotTranslated ? "ltr" : "unset"}
179179
>
180-
<BannerNotification shouldShow zIndex="sticky" hideBelow={lgBp}>
180+
<BannerNotification shouldShow className="z-sticky max-lg:hidden">
181181
<Emoji text=":pencil:" className="me-4 shrink-0 text-2xl" />
182182
<Text m={0}>
183183
{t("template-usecase:template-usecase-banner")}{" "}

0 commit comments

Comments
 (0)