Skip to content

Commit a19f8f3

Browse files
authored
Merge pull request #13820 from ethereum/banner-notification
feat: migrate BannerNotification to tw
2 parents b68b738 + 6bb8658 commit a19f8f3

File tree

3 files changed

+31
-40
lines changed

3 files changed

+31
-40
lines changed

src/components/Banners/BannerNotification.tsx

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,26 @@
1-
import React from "react"
2-
import { Center, FlexProps, useMediaQuery } from "@chakra-ui/react"
1+
import { cn } from "@/lib/utils/cn"
32

4-
import { lightTheme as oldTheme } from "../../theme"
5-
6-
export type BannerNotificationProps = FlexProps & {
3+
export type BannerNotificationProps = React.HTMLAttributes<HTMLDivElement> & {
74
shouldShow?: boolean
85
}
96

107
const BannerNotification = ({
118
children,
12-
shouldShow = false,
9+
shouldShow,
10+
className,
1311
...props
1412
}: BannerNotificationProps) => {
15-
const [isLGScreen] = useMediaQuery(`min-width: ${oldTheme.breakpoints.l}`)
13+
if (!shouldShow) return <></>
1614
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>
15+
<aside
16+
className={cn(
17+
"flex items-center justify-center gap-2 bg-primary-action px-8 py-4 text-white [&_a]:text-white [&_a]:hover:text-white/80",
18+
className
3619
)}
37-
</>
20+
{...props}
21+
>
22+
{children}
23+
</aside>
3824
)
3925
}
4026

src/components/Banners/DismissableBanner/index.tsx

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
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"
6+
7+
import { cn } from "@/lib/utils/cn"
48

5-
// Components
69
import BannerNotification from "../BannerNotification"
710

8-
// Interface
9-
export type DismissableBannerProps = {
10-
children: JSX.Element
11+
type DismissableBannerProps = React.HTMLAttributes<HTMLDivElement> & {
1112
storageKey: string
1213
}
1314

1415
const DismissableBanner = ({
1516
children,
1617
storageKey,
18+
className,
1719
}: DismissableBannerProps) => {
1820
const [show, setShow] = useState<boolean>(false)
1921

@@ -28,13 +30,16 @@ const DismissableBanner = ({
2830
}
2931

3032
return (
31-
<BannerNotification shouldShow={show} gap="8">
32-
<Center marginInlineStart="auto">{children}</Center>
33-
<CloseButton
34-
marginInlineStart="auto"
33+
<BannerNotification shouldShow={show} className={cn("gap-8", className)}>
34+
<Center className="ms-auto">{children}</Center>
35+
<Button
36+
className="ms-auto"
3537
onClick={onClose}
3638
aria-label="Close Banner"
37-
/>
39+
variant="ghost"
40+
>
41+
<MdClose />
42+
</Button>
3843
</BannerNotification>
3944
)
4045
}

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)