-
Notifications
You must be signed in to change notification settings - Fork 378
add role navigation and semantic list to left panel nav #1047
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2,7 +2,7 @@ import { usePathname, useRouter, useSearchParams } from 'next/navigation'; | |||||||||||||||
import { useTranslation } from 'react-i18next'; | ||||||||||||||||
import { css } from 'styled-components'; | ||||||||||||||||
|
||||||||||||||||
import { Box, BoxButton, Icon, Text } from '@/components'; | ||||||||||||||||
import { BoxButton, Icon, Text } from '@/components'; | ||||||||||||||||
import { useCunninghamTheme } from '@/cunningham'; | ||||||||||||||||
import { DocDefaultFilter } from '@/features/docs'; | ||||||||||||||||
import { useLeftPanelStore } from '@/features/left-panel'; | ||||||||||||||||
|
@@ -47,48 +47,50 @@ export const LeftPanelTargetFilters = () => { | |||||||||||||||
}; | ||||||||||||||||
|
||||||||||||||||
return ( | ||||||||||||||||
<Box | ||||||||||||||||
$justify="center" | ||||||||||||||||
$padding={{ horizontal: 'sm' }} | ||||||||||||||||
$gap={spacingsTokens['2xs']} | ||||||||||||||||
className="--docs--left-panel-target-filters" | ||||||||||||||||
> | ||||||||||||||||
{defaultQueries.map((query) => { | ||||||||||||||||
const isActive = target === query.targetQuery; | ||||||||||||||||
<nav role="navigation" aria-label="Docs filters"> | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||
<ul | ||||||||||||||||
className="--docs--left-panel-target-filters" | ||||||||||||||||
style={{ listStyle: 'none', padding: 0, margin: 0 }} | ||||||||||||||||
> | ||||||||||||||||
{defaultQueries.map((query) => { | ||||||||||||||||
const isActive = target === query.targetQuery; | ||||||||||||||||
|
||||||||||||||||
return ( | ||||||||||||||||
<BoxButton | ||||||||||||||||
aria-label={query.label} | ||||||||||||||||
key={query.label} | ||||||||||||||||
onClick={() => onSelectQuery(query.targetQuery)} | ||||||||||||||||
$direction="row" | ||||||||||||||||
aria-selected={isActive} | ||||||||||||||||
$align="center" | ||||||||||||||||
$justify="flex-start" | ||||||||||||||||
$gap={spacingsTokens['xs']} | ||||||||||||||||
$radius={spacingsTokens['3xs']} | ||||||||||||||||
$padding={{ all: '2xs' }} | ||||||||||||||||
$css={css` | ||||||||||||||||
cursor: pointer; | ||||||||||||||||
background-color: ${isActive | ||||||||||||||||
? colorsTokens['greyscale-100'] | ||||||||||||||||
: undefined}; | ||||||||||||||||
font-weight: ${isActive ? 700 : undefined}; | ||||||||||||||||
&:hover { | ||||||||||||||||
background-color: ${colorsTokens['greyscale-100']}; | ||||||||||||||||
} | ||||||||||||||||
`} | ||||||||||||||||
> | ||||||||||||||||
<Icon | ||||||||||||||||
$variation={isActive ? '1000' : '700'} | ||||||||||||||||
iconName={query.icon} | ||||||||||||||||
/> | ||||||||||||||||
<Text $variation={isActive ? '1000' : '700'} $size="sm"> | ||||||||||||||||
{query.label} | ||||||||||||||||
</Text> | ||||||||||||||||
</BoxButton> | ||||||||||||||||
); | ||||||||||||||||
})} | ||||||||||||||||
</Box> | ||||||||||||||||
return ( | ||||||||||||||||
<li key={query.label}> | ||||||||||||||||
<BoxButton | ||||||||||||||||
aria-label={query.label} | ||||||||||||||||
onClick={() => onSelectQuery(query.targetQuery)} | ||||||||||||||||
$direction="row" | ||||||||||||||||
aria-selected={isActive} | ||||||||||||||||
$align="center" | ||||||||||||||||
$justify="flex-start" | ||||||||||||||||
$gap={spacingsTokens['xs']} | ||||||||||||||||
$radius={spacingsTokens['3xs']} | ||||||||||||||||
$padding={{ all: '2xs' }} | ||||||||||||||||
$css={css` | ||||||||||||||||
width: 100%; | ||||||||||||||||
cursor: pointer; | ||||||||||||||||
background-color: ${isActive | ||||||||||||||||
? colorsTokens['greyscale-100'] | ||||||||||||||||
: undefined}; | ||||||||||||||||
font-weight: ${isActive ? 700 : undefined}; | ||||||||||||||||
&:hover { | ||||||||||||||||
background-color: ${colorsTokens['greyscale-100']}; | ||||||||||||||||
} | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There’s no visible focus outline, so it's hard to know where we are. 👉 You may need to explicitly add a :focus-visible style on the BoxButton to restore proper keyboard visibility.
Suggested change
![]() |
||||||||||||||||
`} | ||||||||||||||||
> | ||||||||||||||||
<Icon | ||||||||||||||||
$variation={isActive ? '1000' : '700'} | ||||||||||||||||
iconName={query.icon} | ||||||||||||||||
/> | ||||||||||||||||
<Text $variation={isActive ? '1000' : '700'} $size="sm"> | ||||||||||||||||
{query.label} | ||||||||||||||||
</Text> | ||||||||||||||||
</BoxButton> | ||||||||||||||||
</li> | ||||||||||||||||
); | ||||||||||||||||
})} | ||||||||||||||||
</ul> | ||||||||||||||||
</nav> | ||||||||||||||||
); | ||||||||||||||||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello Thanks for the semantic update !
You can remove role="navigation", as it’s implicit on the nav element. It’s only necessary if you're using a non-semantic container like a div.
and Also, consider updating the aria-label something like "Document sections" would be more meaningful for screen reader users than "Docs filters".