Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: accessibility of the mobile nav bar #7427

Merged
merged 9 commits into from
Feb 1, 2025
Merged
8 changes: 7 additions & 1 deletion apps/site/components/Containers/NavBar/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,18 @@
dark:border-neutral-900;
}

.sidebarItemToggler {
@apply absolute right-4 -z-10 appearance-none opacity-0;
transform: translateY(-200%);
}

.nodeIconWrapper {
@apply h-[30px]
flex-1;
}

.navInteractionIcon {
.navInteractionIcon,
.sidebarItemToggler {
@apply size-6;
}

Expand Down
10 changes: 8 additions & 2 deletions apps/site/components/Containers/NavBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import Hamburger from '@heroicons/react/24/solid/Bars3Icon';
import XMark from '@heroicons/react/24/solid/XMarkIcon';
import * as Label from '@radix-ui/react-label';
import classNames from 'classnames';
import dynamic from 'next/dynamic';
import { useState } from 'react';
import type { FC, ComponentProps, HTMLAttributeAnchorTarget } from 'react';
Expand Down Expand Up @@ -55,15 +56,20 @@ const NavBar: FC<NavbarProps> = ({
</Link>

<Label.Root
onClick={() => setIsMenuOpen(prev => !prev)}
className={style.sidebarItemTogglerLabel}
htmlFor="sidebarItemToggler"
>
{navInteractionIcons[isMenuOpen ? 'close' : 'show']}
</Label.Root>
</div>

<input className="peer hidden" id="sidebarItemToggler" type="checkbox" />
<input
className={classNames(['peer', style.sidebarItemToggler])}
id="sidebarItemToggler"
type="checkbox"
onChange={e => setIsMenuOpen(() => e.target.checked)}
aria-label={`${isMenuOpen ? 'Close' : 'Show'} navigation menu`}
/>

<div className={`${style.main} peer-checked:flex`}>
<div className={style.navItems}>
Expand Down
1 change: 1 addition & 0 deletions apps/site/components/Icons/Logos/Nodejs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const Nodejs: FC<NodeJsLogoProps> = ({
height="80"
viewBox="0 0 267 80"
fill="none"
aria-label="Node.js logo"
xmlns="http://www.w3.org/2000/svg"
className={classNames('fill-[#333333] dark:fill-white', className)}
{...props}
Expand Down
4 changes: 3 additions & 1 deletion packages/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
},
"navBar": {
"links": {
"open": "Show navigation menu",
"close": "Close navigation menu",
"about": "About",
"download": "Download",
"docs": "Docs",
Expand Down Expand Up @@ -285,4 +287,4 @@
}
}
}
}
}
Loading