File tree Expand file tree Collapse file tree 2 files changed +32
-22
lines changed
src/components/LanguagePicker Expand file tree Collapse file tree 2 files changed +32
-22
lines changed Original file line number Diff line number Diff line change
1
+ import { MouseEventHandler } from "react"
2
+ import { useTranslation } from "next-i18next"
3
+ import { Flex } from "@chakra-ui/react"
4
+
5
+ import { Button } from "@/components/Buttons"
6
+
7
+ type MobileCloseBarProps = {
8
+ handleClick : MouseEventHandler < HTMLButtonElement >
9
+ }
10
+
11
+ export const MobileCloseBar = ( { handleClick } : MobileCloseBarProps ) => {
12
+ const { t } = useTranslation ( )
13
+
14
+ return (
15
+ < Flex
16
+ justifyContent = "end"
17
+ hideFrom = "md"
18
+ position = "sticky"
19
+ zIndex = "sticky"
20
+ top = "0"
21
+ bg = "background.base"
22
+ >
23
+ < Button p = "4" variant = "ghost" alignSelf = "end" onClick = { handleClick } >
24
+ { t ( "close" ) }
25
+ </ Button >
26
+ </ Flex >
27
+ )
28
+ }
Original file line number Diff line number Diff line change @@ -18,12 +18,12 @@ import {
18
18
19
19
import { LocaleDisplayInfo } from "@/lib/types"
20
20
21
- import { Button } from "@/components/Buttons"
22
21
import { BaseLink } from "@/components/Link"
23
22
24
23
import { isMobile } from "@/lib/utils/isMobile"
25
24
26
25
import MenuItem from "./MenuItem"
26
+ import { MobileCloseBar } from "./MobileCloseBar"
27
27
import NoResultsCallout from "./NoResultsCallout"
28
28
import { useLanguagePicker } from "./useLanguagePicker"
29
29
@@ -76,26 +76,6 @@ const LanguagePicker = ({
76
76
eventName : "/contributing/translation-program" ,
77
77
} )
78
78
79
- const MobileCloseBar = ( ) => (
80
- < Flex
81
- justifyContent = "end"
82
- hideFrom = "md"
83
- position = "sticky"
84
- zIndex = "sticky"
85
- top = "0"
86
- bg = "background.base"
87
- >
88
- < Button
89
- p = "4"
90
- variant = "ghost"
91
- alignSelf = "end"
92
- onClick = { handleMobileCloseBarClick }
93
- >
94
- { t ( "common:close" ) }
95
- </ Button >
96
- </ Flex >
97
- )
98
-
99
79
return (
100
80
< Menu isLazy placement = { placement } autoSelect = { false } { ...disclosure } >
101
81
{ children }
@@ -114,7 +94,9 @@ const LanguagePicker = ({
114
94
>
115
95
{ /* Mobile Close bar */ }
116
96
{ /* avoid rendering mobile only feature on desktop */ }
117
- { isMobile ( ) && < MobileCloseBar /> }
97
+ { isMobile ( ) && (
98
+ < MobileCloseBar handleClick = { handleMobileCloseBarClick } />
99
+ ) }
118
100
119
101
{ /* Main Language selection menu */ }
120
102
< Box
You can’t perform that action at this time.
0 commit comments