Skip to content

Commit 7da41fc

Browse files
authored
Merge pull request #345 from codesnippetspro/a11y-toolbar
Fix: accessible code snippets toolbar
2 parents f83d2d6 + fecb95e commit 7da41fc

1 file changed

Lines changed: 23 additions & 20 deletions

File tree

src/js/components/common/Toolbar.tsx

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,13 @@ const UpperNav: React.FC<NavProps> = ({ setIsUpsellDialogOpen }) =>
7878
<img
7979
src={`${window.CODE_SNIPPETS?.urls.plugin}/assets/icon.svg`}
8080
alt={__('Code Snippets logo', 'code-snippets')}
81+
aria-hidden="true"
8182
/>
8283

8384
<h1>{__('Code Snippets', 'code-snippets')}</h1>
8485
</div>
8586

86-
<nav>
87+
<nav aria-label={__('Main links', 'code-snippets')}>
8788
<ul>
8889
{UPPER_NAV_LINKS.map(({ name, url, label, external }) =>
8990
<li key={name}>
@@ -119,25 +120,27 @@ const currentPage = fetchQueryParam('subpage') ?? fetchQueryParam('page')
119120

120121
const LowerNav: React.FC<NavProps> = ({ setIsUpsellDialogOpen }) =>
121122
<div className="code-snippets-toolbar-lower">
122-
<ul>
123-
{LOWER_NAV_LINKS.map(({ name, url, label, pro, icon }) =>
124-
<li key={name}>
125-
<a
126-
href={url ?? buildUrl(window.CODE_SNIPPETS?.urls.manage, { subpage: name })}
127-
className={classnames(`${name}-link`, { 'active-link': currentPage?.endsWith(name) })}
128-
onClick={event => {
129-
if (pro && !isLicensed()) {
130-
event.preventDefault()
131-
setIsUpsellDialogOpen(true)
132-
}
133-
}}
134-
>
135-
{icon}
136-
<span>{label}</span>
137-
{pro && !isLicensed() && <span className="pro-chip">{__('Pro', 'code-snippets')}</span>}
138-
</a>
139-
</li>)}
140-
</ul>
123+
<nav aria-label={__('Main features', 'code-snippets')}>
124+
<ul>
125+
{LOWER_NAV_LINKS.map(({ name, url, label, pro, icon }) =>
126+
<li key={name}>
127+
<a
128+
href={url ?? buildUrl(window.CODE_SNIPPETS?.urls.manage, { subpage: name })}
129+
className={classnames(`${name}-link`, { 'active-link': currentPage?.endsWith(name) })}
130+
onClick={event => {
131+
if (pro && !isLicensed()) {
132+
event.preventDefault()
133+
setIsUpsellDialogOpen(true)
134+
}
135+
}}
136+
>
137+
{icon}
138+
<span>{label}</span>
139+
{pro && !isLicensed() && <span className="pro-chip">{__('Pro', 'code-snippets')}</span>}
140+
</a>
141+
</li>)}
142+
</ul>
143+
</nav>
141144
</div>
142145

143146
export const Toolbar = () => {

0 commit comments

Comments
 (0)