Skip to content

Commit feb86b5

Browse files
authored
Merge pull request #14511 from ameeetgaikwad/TranslationBannerLegal
🦄 refactor: Migrated `TranslationBannerLegal.tsx` to shadcn
2 parents fd389ec + 42a567a commit feb86b5

File tree

1 file changed

+42
-68
lines changed

1 file changed

+42
-68
lines changed

src/components/TranslationBannerLegal.tsx

Lines changed: 42 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
import React, { useEffect, useState } from "react"
2-
import {
3-
Box,
4-
Button,
5-
CloseButton,
6-
Flex,
7-
Heading,
8-
useToken,
9-
} 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+
6+
import { cn } from "@/lib/utils/cn"
107

118
import Emoji from "./Emoji"
12-
import Text from "./OldText"
139
import Translation from "./Translation"
1410

1511
export type TranslationBannerLegalProps = {
@@ -23,7 +19,6 @@ const TranslationBannerLegal = ({
2319
}: TranslationBannerLegalProps) => {
2420
// Default to isOpen being false, and let the useEffect set this.
2521
const [isOpen, setIsOpen] = useState(false)
26-
const text = useToken("colors", "text")
2722

2823
useEffect(() => {
2924
if (
@@ -38,53 +33,33 @@ const TranslationBannerLegal = ({
3833
}, [originalPagePath, shouldShow])
3934

4035
return (
41-
<Box
42-
as="aside"
43-
position="fixed"
44-
display={isOpen ? "block" : "none"}
45-
bottom={{ base: 0, md: 8 }}
46-
insetInlineEnd={{ base: 0, md: 8 }}
47-
zIndex="99"
36+
<aside
37+
className={cn(
38+
"fixed z-popover bg-background-highlight",
39+
"bottom-0 md:bottom-8",
40+
"right-0 md:right-8",
41+
isOpen ? "block" : "hidden"
42+
)}
4843
>
49-
<Flex
50-
bg="infoBanner"
51-
color="black300"
52-
justify="space-between"
53-
maxW={{ base: "full", md: "600px" }}
54-
maxH="full"
55-
p={4}
56-
borderRadius="sm"
57-
boxShadow={{
58-
base: `-4px 10px 0px ${text} 10%`,
59-
md: "rgba(0, 0, 0, 0.16) 0px 2px 4px 0px",
60-
}}
44+
<div
45+
className={cn(
46+
"relative flex justify-between",
47+
"w-full md:max-w-[600px]",
48+
"rounded-sm p-4",
49+
"shadow-md"
50+
)}
6151
>
62-
<Flex direction="column" m={4} mt={{ base: 10, sm: 4 }}>
63-
<Flex
64-
align={{ base: "flex-start", sm: "center" }}
65-
flexDirection={{ base: "column-reverse", sm: "row" }}
66-
mb={4}
67-
>
68-
<Heading
69-
as="h3"
70-
fontSize={{ base: "1.25rem", md: "1.5rem" }}
71-
fontWeight="bold"
72-
lineHeight="100%"
73-
>
52+
<div className="m-4 mt-10 flex flex-col gap-4 sm:mt-4">
53+
<div className="flex flex-col-reverse items-start sm:flex-row sm:items-center">
54+
<h3 className="leading-none md:text-2xl">
7455
<Translation id="translation-banner-no-bugs-title" />
75-
<Emoji
76-
text=":bug:"
77-
className="mb-4 ms-2 pt-2 text-3xl sm:mb-auto"
78-
/>
79-
</Heading>
80-
</Flex>
81-
<Text>
56+
<Emoji text=":bug:" className="ms-2 text-3xl sm:mb-auto" />
57+
</h3>
58+
</div>
59+
<p>
8260
<Translation id="translation-banner-no-bugs-content" />
83-
</Text>
84-
<Flex
85-
align={{ base: "flex-start", sm: "center" }}
86-
flexDirection={{ base: "column", sm: "row" }}
87-
>
61+
</p>
62+
<div className="flex flex-col items-start sm:flex-row sm:items-center">
8863
<Button
8964
onClick={() => {
9065
localStorage.setItem(
@@ -96,21 +71,20 @@ const TranslationBannerLegal = ({
9671
>
9772
<Translation id="translation-banner-no-bugs-dont-show-again" />
9873
</Button>
99-
</Flex>
100-
</Flex>
101-
<CloseButton
102-
position="absolute"
103-
top={0}
104-
insetInlineEnd="0"
105-
margin={4}
106-
color="secondary"
107-
_hover={{
108-
color: "primary.base",
109-
}}
74+
</div>
75+
</div>
76+
<Button
77+
variant="ghost"
78+
className={cn(
79+
"absolute right-0 top-0 m-4 p-2",
80+
"text-secondary hover:text-primary"
81+
)}
11082
onClick={() => setIsOpen(false)}
111-
/>
112-
</Flex>
113-
</Box>
83+
>
84+
<MdClose className="h-4 w-4" />
85+
</Button>
86+
</div>
87+
</aside>
11488
)
11589
}
11690

0 commit comments

Comments
 (0)