1
1
import { useEffect , useState } from "react"
2
+ import Link from "next/link"
2
3
import { useRouter } from "next/router"
3
4
import { useTranslation } from "next-i18next"
4
- import { Box , CloseButton , Flex , Heading , useToken } from "@chakra-ui/react "
5
+ import { MdClose } from "react-icons/md "
5
6
6
7
import type { Lang } from "@/lib/types"
7
8
9
+ import { Button } from "@/components/ui/buttons/Button"
10
+ import { Flex } from "@/components/ui/flex"
11
+
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"
@@ -39,91 +41,58 @@ const TranslationBanner = ({
39
41
? "translation-banner-body-new"
40
42
: "translation-banner-body-update"
41
43
44
+ if ( ! isOpen ) return null
45
+
42
46
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"
50
- dir = { dir }
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
- >
47
+ < aside className = "fixed bottom-0 end-0 z-50 md:bottom-8 md:end-8" dir = { dir } >
48
+ < div className = "bg-info-banner relative max-h-full max-w-full p-4 text-neutral-900 shadow-md md:max-w-[600px] md:rounded-sm" >
49
+ < Flex className = "m-4 mt-10 flex-col sm:mt-4" >
50
+ < Flex className = "mb-4 flex-col-reverse items-start sm:flex-row sm:items-center" >
51
+ < h3 className = "my-0 text-2xl font-bold leading-none" >
78
52
{ t ( headerTextId ) }
79
- </ Heading >
53
+ </ h3 >
80
54
< Emoji
81
55
text = ":globe_showing_asia_australia:"
82
56
className = "mb-4 ms-2 text-2xl sm:mb-auto"
83
57
/>
84
58
</ Flex >
85
59
< p > { t ( bodyTextId ) } </ p >
86
- < Flex
87
- align = { { base : "flex-start" , sm : "center" } }
88
- flexDirection = { { base : "column" , sm : "row" } }
89
- >
90
- < Box >
91
- < ButtonLink href = "/contributing/translation-program/" >
92
- { t ( "translation-banner-button-translate-page" ) }
93
- </ ButtonLink >
94
- </ Box >
60
+ < Flex className = "flex-col items-start sm:flex-row sm:items-center" >
61
+ < div >
62
+ < Button asChild variant = "solid" >
63
+ < Link href = "/contributing/translation-program/" >
64
+ { t ( "translation-banner-button-translate-page" ) }
65
+ </ Link >
66
+ </ Button >
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