Skip to content

Commit 0b18ab1

Browse files
authored
fix: add aria-label prop on nav links (#7580)
1 parent 6c151c2 commit 0b18ab1

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/components/Navigation/Navigation.jsx

+12-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ NavigationItem.propTypes = {
2222
children: PropTypes.node.isRequired,
2323
url: PropTypes.string.isRequired,
2424
isactive: PropTypes.func,
25+
ariaLabel: PropTypes.string,
2526
};
2627

27-
function NavigationItem({ children, url, isactive }) {
28+
function NavigationItem({ children, url, isactive, ariaLabel }) {
2829
let obj = {};
2930
// decide if the link is active or not by providing a function
3031
// otherwise we'll let react-dom makes the decision for us
@@ -42,6 +43,7 @@ function NavigationItem({ children, url, isactive }) {
4243
target="_blank"
4344
rel="noopener noreferrer"
4445
className={classes}
46+
aria-label={ariaLabel}
4547
>
4648
{children}
4749
</a>
@@ -54,6 +56,7 @@ function NavigationItem({ children, url, isactive }) {
5456
isActive ? `${classes} !text-blue-200` : classes
5557
}
5658
to={url}
59+
aria-label={ariaLabel}
5760
>
5861
{children}
5962
</NavLink>
@@ -71,6 +74,7 @@ function NavigationIcon({ children, to, title }) {
7174
to={to}
7275
className="inline-flex items-center text-gray-100 dark:text-gray-200 hover:text-blue-200"
7376
title={`webpack on ${title}`}
77+
aria-label={`webpack on ${title}`}
7478
>
7579
{children}
7680
</Link>
@@ -118,8 +122,13 @@ function Navigation({ links, pathname, hash = '', toggleSidebar }) {
118122
<Logo />
119123
</Link>
120124
<nav className="hidden md:inline-grid md:grid-flow-col md:gap-x-[18px]">
121-
{links.map(({ content, url, isActive }) => (
122-
<NavigationItem key={url} url={url} isActive={isActive}>
125+
{links.map(({ content, url, isActive, ariaLabel }) => (
126+
<NavigationItem
127+
key={url}
128+
url={url}
129+
isActive={isActive}
130+
ariaLabel={ariaLabel}
131+
>
123132
{content}
124133
</NavigationItem>
125134
))}

src/components/Site/Site.jsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ function Site(props) {
224224
links={[
225225
{
226226
content: 'Documentation',
227+
ariaLabel: 'webpack documentation',
227228
url: '/concepts/',
228229
isactive: (_, location) => {
229230
return /^\/(api|concepts|configuration|guides|loaders|migrate|plugins)/.test(
@@ -236,8 +237,12 @@ function Site(props) {
236237
)
237238
),
238239
},
239-
{ content: 'Contribute', url: '/contribute/' },
240-
{ content: 'Blog', url: '/blog/' },
240+
{
241+
content: 'Contribute',
242+
url: '/contribute/',
243+
ariaLabel: 'contribute to webpack',
244+
},
245+
{ content: 'Blog', url: '/blog/', ariaLabel: 'webpack blog' },
241246
]}
242247
/>
243248
</div>

0 commit comments

Comments
 (0)