Skip to content

Commit 19393a2

Browse files
committed
fix desktop
1 parent 1a86d1d commit 19393a2

File tree

2 files changed

+35
-45
lines changed

2 files changed

+35
-45
lines changed

src/components/Nav/Mobile.js

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import styled from "styled-components"
33
import { useIntl } from "gatsby-plugin-intl"
44
import { motion } from "framer-motion"
55

6+
import NakedButton from "../NakedButton"
67
import Translation from "../Translation"
78
import Icon from "../Icon"
89
import Link from "../Link"
@@ -11,6 +12,25 @@ import Emoji from "../Emoji"
1112
import { NavLink } from "../../components/SharedStyledComponents"
1213
import { translateMessageId } from "../../utils/translations"
1314

15+
const Container = styled.div`
16+
display: none;
17+
@media (max-width: ${(props) => props.theme.breakpoints.l}) {
18+
display: flex;
19+
}
20+
`
21+
22+
const MenuIcon = styled(Icon)`
23+
fill: ${(props) => props.theme.colors.text};
24+
`
25+
26+
const MenuButton = styled(NakedButton)`
27+
margin-left: 1rem;
28+
`
29+
30+
const SearchIcon = styled(MenuIcon)`
31+
margin-right: 1rem;
32+
`
33+
1434
const MobileModal = styled(motion.div)`
1535
position: fixed;
1636
background: ${(props) => props.theme.colors.modalBackground};
@@ -179,10 +199,6 @@ const BottomItemText = styled.div`
179199
}
180200
`
181201

182-
const MenuIcon = styled(Icon)`
183-
fill: ${(props) => props.theme.colors.text};
184-
`
185-
186202
const BlankSearchState = styled.div`
187203
color: ${(props) => props.theme.colors.text};
188204
background: ${(props) => props.theme.colors.searchBackgroundEmpty};
@@ -211,14 +227,27 @@ const MobileNavMenu = ({
211227

212228
const isOpen = isMenuOpen || isSearchOpen
213229
return (
214-
<>
230+
<Container>
231+
<MenuButton
232+
onClick={() => toggleMenu("search")}
233+
aria-label={translateMessageId("aria-toggle-search-button", intl)}
234+
>
235+
<SearchIcon name="search" />
236+
</MenuButton>
237+
<MenuButton
238+
onClick={() => toggleMenu("menu")}
239+
aria-label={translateMessageId("aria-toggle-menu-button", intl)}
240+
>
241+
<MenuIcon name="menu" />
242+
</MenuButton>
215243
<MobileModal
216244
animate={isOpen ? "open" : "closed"}
217245
variants={mobileModalVariants}
218246
initial="closed"
219247
onClick={toggleMenu}
220248
/>
221249
<MenuContainer
250+
aria-hidden={isMenuOpen ? false : true}
222251
animate={isMenuOpen ? "open" : "closed"}
223252
variants={mobileMenuVariants}
224253
initial="closed"
@@ -301,7 +330,7 @@ const MobileNavMenu = ({
301330
<Translation id="search-box-blank-state-text" />
302331
</BlankSearchState>
303332
</SearchContainer>
304-
</>
333+
</Container>
305334
)
306335
}
307336

src/components/Nav/index.js

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ const NavContent = styled.div`
5454
justify-content: space-between;
5555
}
5656
`
57-
const NavMobileButton = styled(NakedButton)`
58-
margin-left: 1rem;
59-
`
6057

6158
const InnerContent = styled.div`
6259
display: flex;
@@ -131,26 +128,6 @@ const NavIcon = styled(Icon)`
131128
fill: ${(props) => props.theme.colors.text};
132129
`
133130

134-
const MenuIcon = styled(Icon)`
135-
fill: ${(props) => props.theme.colors.text};
136-
display: none;
137-
@media (max-width: ${(props) => props.theme.breakpoints.l}) {
138-
display: block;
139-
cursor: pointer;
140-
}
141-
`
142-
143-
const MobileIcons = styled.div`
144-
display: none;
145-
@media (max-width: ${(props) => props.theme.breakpoints.l}) {
146-
display: flex;
147-
}
148-
`
149-
150-
const SearchIcon = styled(MenuIcon)`
151-
margin-right: 1rem;
152-
`
153-
154131
// TODO display page title on mobile
155132
const Nav = ({ handleThemeChange, isDarkTheme, path }) => {
156133
const [isMenuOpen, setIsMenuOpen] = useState(false)
@@ -393,24 +370,8 @@ const Nav = ({ handleThemeChange, isDarkTheme, path }) => {
393370
toggleTheme={handleThemeChange}
394371
linkSections={mobileLinkSections}
395372
/>
396-
<MobileIcons>
397-
<NavMobileButton
398-
onClick={() => handleMenuToggle("search")}
399-
aria-label={translateMessageId("aria-toggle-search-button", intl)}
400-
>
401-
<SearchIcon name="search" />
402-
</NavMobileButton>
403-
404-
<NavMobileButton
405-
onClick={() => handleMenuToggle("menu")}
406-
aria-label={translateMessageId("aria-toggle-menu-button", intl)}
407-
>
408-
<MenuIcon name="menu" />
409-
</NavMobileButton>
410-
</MobileIcons>
411373
</NavContent>
412374
</StyledNav>
413-
414375
{shouldShowSubNav && (
415376
<SubNav>
416377
{ednLinks.map((link, idx) => (

0 commit comments

Comments
 (0)