1
1
import { useEffect , useState } from "react"
2
2
import { useRouter } from "next/router"
3
3
import { useTranslation } from "next-i18next"
4
- import { Box , CloseButton , Flex , Heading , useToken } from "@chakra-ui/react "
4
+ import { MdClose } from "react-icons/md "
5
5
6
6
import type { Lang } from "@/lib/types"
7
7
8
+ import { Button , ButtonLink } from "@/components/ui/buttons/Button"
9
+ import { Flex } from "@/components/ui/flex"
10
+
11
+ import { cn } from "@/lib/utils/cn"
8
12
import { isLangRightToLeft } from "@/lib/utils/translations"
9
13
10
- import { ButtonLink } from "./Buttons"
11
14
import Emoji from "./Emoji"
12
15
13
16
export type TranslationBannerProps = {
@@ -22,7 +25,6 @@ const TranslationBanner = ({
22
25
isPageContentEnglish,
23
26
} : TranslationBannerProps ) => {
24
27
const [ isOpen , setIsOpen ] = useState ( shouldShow )
25
- const [ textColor ] = useToken ( "colors" , [ "text" ] )
26
28
const { t } = useTranslation ( "common" )
27
29
const { locale } = useRouter ( )
28
30
const dir = isLangRightToLeft ( locale ! as Lang ) ? "rtl" : "ltr"
@@ -40,90 +42,57 @@ const TranslationBanner = ({
40
42
: "translation-banner-body-update"
41
43
42
44
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
+ ) }
50
50
dir = { dir }
51
51
>
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 >
80
56
< Emoji
81
57
text = ":globe_showing_asia_australia:"
82
58
className = "mb-4 ms-2 text-2xl sm:mb-auto"
83
59
/>
84
60
</ Flex >
85
61
< 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 >
91
64
< ButtonLink href = "/contributing/translation-program/" >
92
65
{ t ( "translation-banner-button-translate-page" ) }
93
66
</ ButtonLink >
94
- </ Box >
67
+ </ div >
95
68
{ /* Todo: Reimplement once fixed */ }
96
69
{ /* Issue: https://github.com/ethereum/ethereum-org-website/issues/12292 */ }
97
70
{ /* {!isPageContentEnglish && (
98
- <Box >
99
- <ButtonLink
100
- href={originalPagePath}
71
+ <div >
72
+ <Button
73
+ asChild
101
74
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"
107
76
>
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>
111
82
)} */ }
112
83
</ Flex >
113
84
</ 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"
123
89
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 >
127
96
)
128
97
}
129
98
0 commit comments