Skip to content

Commit 33f74f1

Browse files
committed
refactor(banner-notification): migrate component to chakra ui
the component has been migrated to chakra ui. The emotion styled component has been removed from the file Refs: #6374
1 parent b0d2ab3 commit 33f74f1

File tree

1 file changed

+29
-27
lines changed

1 file changed

+29
-27
lines changed

src/components/BannerNotification.tsx

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,43 @@
11
import React from "react"
2-
import styled from "@emotion/styled"
3-
4-
export interface IStyledBanner {
5-
shouldShow: boolean
6-
}
2+
import { Flex, useMediaQuery } from "@chakra-ui/react"
3+
import { lightTheme as oldTheme } from "../theme"
74

85
export interface IProps {
96
children?: React.ReactNode
107
shouldShow?: boolean
118
className?: string
129
}
1310

14-
const Banner = styled.div<IStyledBanner>`
15-
display: ${(props) => (props.shouldShow ? `flex` : `none`)};
16-
width: 100%;
17-
background-color: ${(props) => props.theme.colors.primary};
18-
color: ${(props) => props.theme.colors.background};
19-
padding: 1rem 2rem;
20-
border-bottom: 1px solid ${(props) => props.theme.colors.primary};
21-
22-
a {
23-
color: ${(props) => props.theme.colors.background} !important;
24-
}
25-
26-
@media (min-width: ${(props) => props.theme.breakpoints.l}) {
27-
max-width: ${(props) => props.theme.variables.maxPageWidth};
28-
}
29-
`
30-
3111
const BannerNotification: React.FC<IProps> = ({
3212
children,
3313
className,
3414
shouldShow = false,
35-
}) => (
36-
<Banner shouldShow={shouldShow} className={className}>
37-
{children}
38-
</Banner>
39-
)
15+
}) => {
16+
const [isLGScreen] = useMediaQuery(`min-width: ${oldTheme.breakpoints.l}`)
17+
18+
return (
19+
<>
20+
{shouldShow && (
21+
<Flex
22+
className={className}
23+
maxW={isLGScreen ? oldTheme.variables.maxPageWidth : "100%"}
24+
w="100%"
25+
py="4"
26+
px="8"
27+
bg="primary"
28+
color="background"
29+
borderBottom="1px solid primary"
30+
sx={{
31+
a: {
32+
color: "background",
33+
},
34+
}}
35+
>
36+
{children}
37+
</Flex>
38+
)}
39+
</>
40+
)
41+
}
4042

4143
export default BannerNotification

0 commit comments

Comments
 (0)