Skip to content

Commit a383c82

Browse files
authored
Merge pull request #14546 from ameeetgaikwad/TranslationBanner
refactor: migrated TransaltionBanner
2 parents eda686f + 4fdff2d commit a383c82

File tree

1 file changed

+36
-67
lines changed

1 file changed

+36
-67
lines changed

src/components/TranslationBanner.tsx

Lines changed: 36 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import { useEffect, useState } from "react"
22
import { useRouter } from "next/router"
33
import { useTranslation } from "next-i18next"
4-
import { Box, CloseButton, Flex, Heading, useToken } from "@chakra-ui/react"
4+
import { MdClose } from "react-icons/md"
55

66
import type { Lang } from "@/lib/types"
77

8+
import { Button, ButtonLink } from "@/components/ui/buttons/Button"
9+
import { Flex } from "@/components/ui/flex"
10+
11+
import { cn } from "@/lib/utils/cn"
812
import { isLangRightToLeft } from "@/lib/utils/translations"
913

10-
import { ButtonLink } from "./Buttons"
1114
import Emoji from "./Emoji"
1215

1316
export type TranslationBannerProps = {
@@ -22,7 +25,6 @@ const TranslationBanner = ({
2225
isPageContentEnglish,
2326
}: TranslationBannerProps) => {
2427
const [isOpen, setIsOpen] = useState(shouldShow)
25-
const [textColor] = useToken("colors", ["text"])
2628
const { t } = useTranslation("common")
2729
const { locale } = useRouter()
2830
const dir = isLangRightToLeft(locale! as Lang) ? "rtl" : "ltr"
@@ -40,90 +42,57 @@ const TranslationBanner = ({
4042
: "translation-banner-body-update"
4143

4244
return (
43-
<Box
44-
as="aside"
45-
display={isOpen ? "block" : "none"}
46-
bottom={{ base: 0, md: 8 }}
47-
insetInlineEnd={{ base: 0, md: 8 }}
48-
position="fixed"
49-
zIndex="banner"
45+
<aside
46+
className={cn(
47+
"fixed bottom-0 end-0 z-popover rounded bg-background-highlight md:bottom-8 md:end-8",
48+
isOpen ? "block" : "hidden"
49+
)}
5050
dir={dir}
5151
>
52-
<Flex
53-
p="1rem"
54-
maxH="100%"
55-
maxW={{ base: "100%", md: "600px" }}
56-
bg="infoBanner"
57-
color="black300"
58-
justify="space-between"
59-
boxShadow={{
60-
base: `0px -4px 10px 0px ${textColor} 10%`,
61-
md: "rgba(0, 0, 0, 0.16) 0px 2px 4px 0px",
62-
}}
63-
borderRadius="sm"
64-
>
65-
<Flex flexDirection="column" m={4} mt={{ base: 10, sm: 4 }}>
66-
<Flex
67-
align={{ base: "flex-start", sm: "center" }}
68-
mb={4}
69-
flexDirection={{ base: "column-reverse", sm: "row" }}
70-
>
71-
<Heading
72-
as="h3"
73-
fontSize="2xl"
74-
fontWeight="700"
75-
lineHeight="100%"
76-
my="0"
77-
>
78-
{t(headerTextId)}
79-
</Heading>
52+
<div className="relative max-h-full max-w-full p-4 shadow-md md:max-w-[600px]">
53+
<Flex className="m-4 mt-10 flex-col gap-4 sm:mt-4">
54+
<Flex className="flex-col-reverse items-start sm:flex-row sm:items-center">
55+
<h3 className="leading-none md:text-2xl">{t(headerTextId)}</h3>
8056
<Emoji
8157
text=":globe_showing_asia_australia:"
8258
className="mb-4 ms-2 text-2xl sm:mb-auto"
8359
/>
8460
</Flex>
8561
<p>{t(bodyTextId)}</p>
86-
<Flex
87-
align={{ base: "flex-start", sm: "center" }}
88-
flexDirection={{ base: "column", sm: "row" }}
89-
>
90-
<Box>
62+
<Flex className="flex-col items-start sm:flex-row sm:items-center">
63+
<div>
9164
<ButtonLink href="/contributing/translation-program/">
9265
{t("translation-banner-button-translate-page")}
9366
</ButtonLink>
94-
</Box>
67+
</div>
9568
{/* Todo: Reimplement once fixed */}
9669
{/* Issue: https://github.com/ethereum/ethereum-org-website/issues/12292 */}
9770
{/* {!isPageContentEnglish && (
98-
<Box>
99-
<ButtonLink
100-
href={originalPagePath}
71+
<div>
72+
<Button
73+
asChild
10174
variant="outline"
102-
ms={{ base: 0, sm: 2 }}
103-
mt={{ base: 2, sm: 0 }}
104-
borderColor="#333333"
105-
color="#333333"
106-
lang={DEFAULT_LOCALE}
75+
className="ms-0 sm:ms-2 mt-2 sm:mt-0 border-neutral-900 text-neutral-900"
10776
>
108-
{t("translation-banner-button-see-english")}
109-
</ButtonLink>
110-
</Box>
77+
<a href={originalPagePath} lang={DEFAULT_LOCALE}>
78+
{t("translation-banner-button-see-english")}
79+
</a>
80+
</Button>
81+
</div>
11182
)} */}
11283
</Flex>
11384
</Flex>
114-
<CloseButton
115-
position="absolute"
116-
top="0"
117-
insetInlineEnd="0"
118-
margin={2}
119-
color="secondary"
120-
_hover={{
121-
color: "primary.base",
122-
}}
85+
<Button
86+
variant="ghost"
87+
size="sm"
88+
className="absolute end-0 top-0 m-2 hover:text-primary"
12389
onClick={() => setIsOpen(false)}
124-
/>
125-
</Flex>
126-
</Box>
90+
>
91+
<MdClose className="h-4 w-4" />
92+
<span className="sr-only">Close</span>
93+
</Button>
94+
</div>
95+
</aside>
12796
)
12897
}
12998

0 commit comments

Comments
 (0)