Skip to content

Commit 8e33a3f

Browse files
authored
Merge pull request #54 from rustnl/more-accessible-menubar
Hopefully make the menubar more accessible
2 parents 2e92c54 + d6885ac commit 8e33a3f

File tree

1 file changed

+55
-48
lines changed

1 file changed

+55
-48
lines changed

src/components/page/menu.astro

Lines changed: 55 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,68 @@
11
---
2-
import Button from '../Button.astro';
2+
import Button from "../Button.astro";
33
44
interface Props {
5-
location: 'header' | 'footer';
5+
location: "header" | "footer";
66
}
77
88
const { location }: Props = Astro.props;
99
---
1010

11-
<div class:list={['menu', location]}>
12-
<ul>
13-
<li class="parent">
14-
<a
15-
href="/"
16-
>Home</a
17-
>
11+
<div class:list={["menu", location]} aria-label="Main menu">
12+
<ul role="menubar">
13+
<li class="parent" role="menuitem">
14+
<a href="/">Home</a>
1815
</li>
19-
<li class="parent">
20-
<span>Schedule</span>
21-
<ul class="submenu">
22-
<li class="child">
16+
<li class="parent" role="menuitem">
17+
<button>Schedule</button>
18+
<ul class="submenu" role="menu">
19+
<li class="child" role="menuitem">
2320
<a
2421
href="/overview"
2522
>Overview of the week</a
2623
>
27-
<a href="/schedule/tuesday">Tuesday talks</a>
28-
<a href="/schedule/wednesday">Wednesday Talks</a>
29-
<a href="/workshops">Workshops</a>
24+
<a href="/schedule/tuesday" role="menuitem">Tuesday talks</a>
25+
<a href="/schedule/wednesday" role="menuitem">Wednesday Talks</a>
26+
<a href="/workshops" role="menuitem">Workshops</a>
27+
</li>
28+
<li class="child" role="menuitem">
29+
<a href="/industry">Industry track</a>
3030
</li>
31-
<li class="child"><a href="/industry">Industry track</a></li>
3231
</ul>
3332
</li>
34-
<li class="parent">
35-
<a href="/speakers">Speakers</a>
33+
<li class="parent" role="menuitem">
34+
<a href="/speakers">Speakers</a>
3635
</li>
37-
<li class="parent">
36+
<li class="parent" role="menuitem">
3837
<a
3938
href="/#sponsors"
4039
onclick="document.querySelector('[data-menu-toggle]').click()"
4140
>Sponsors</a
4241
>
4342
</li>
44-
<li class="parent">
45-
<span>Location</span>
46-
<ul class="submenu">
47-
<li class="child">
48-
<a
49-
href="/#where"
50-
onclick="document.querySelector('[data-menu-toggle]').click()">Utrecht</a
51-
>
52-
</li>
53-
<li class="child">
54-
<a href="/kinepolis">Conference venue</a>
55-
</li>
56-
<li class="child">
57-
<a href="/hotels">Hotels</a>
58-
</li>
59-
<li class="child">
60-
<a href="/accessibility">Accessibility</a>
61-
</li>
62-
</ul>
43+
<li class="parent" role="menuitem">
44+
<button>Location</button>
45+
<ul class="submenu" role="menu">
46+
<li class="child" role="menuitem">
47+
<a
48+
href="/#where"
49+
onclick="document.querySelector('[data-menu-toggle]').click()"
50+
>Utrecht</a
51+
>
52+
</li>
53+
<li class="child" role="menuitem">
54+
<a href="/kinepolis">Conference venue</a>
55+
</li>
56+
<li class="child" role="menuitem">
57+
<a href="/hotels">Hotels</a>
58+
</li>
59+
<li class="child" role="menuitem">
60+
<a href="/accessibility">Accessibility</a>
61+
</li>
62+
</ul>
6363
</li>
6464
<li class="parent">
65-
<span>About</span>
65+
<button>About</button>
6666
<ul class="submenu">
6767
<li class="child">
6868
<a href="/about">About</a>
@@ -76,16 +76,15 @@ const { location }: Props = Astro.props;
7676
<Button
7777
link="https://www.eventbrite.nl/e/rust-week-2025-tickets-1001676961757?aff=oddtdtcreator"
7878
ty="primary"
79-
inFooter={location == 'footer'}>Tickets</Button
79+
inFooter={location == "footer"}>Tickets</Button
8080
>
8181
</li>
8282
</ul>
8383
</div>
8484

8585
<style lang="scss">
86-
87-
@use "../../styles/variables.scss";
88-
@use "../../styles/breakpoint.scss";
86+
@use "../../styles/variables.scss";
87+
@use "../../styles/breakpoint.scss";
8988

9089
.menu {
9190
display: contents;
@@ -187,7 +186,8 @@ const { location }: Props = Astro.props;
187186
padding-inline: variables.space(4);
188187
position: relative;
189188

190-
&:has(.submenu):hover {
189+
&:has(.submenu):hover,
190+
&:has(.submenu):focus-within {
191191
--submenu-opacity: 1;
192192
--submenu-visibility: visible;
193193
--submenu-pointer-events: all;
@@ -209,7 +209,14 @@ const { location }: Props = Astro.props;
209209
}
210210
}
211211

212-
.parent span {
212+
.parent button {
213+
background-color: transparent;
214+
border: none;
215+
font-family: inherit;
216+
color: inherit;
217+
font-size: inherit;
218+
font-weight: inherit;
219+
213220
@include breakpoint.wider_than(lg) {
214221
display: flex;
215222
align-items: center;
@@ -218,10 +225,10 @@ const { location }: Props = Astro.props;
218225

219226
&::after {
220227
@include breakpoint.wider_than(lg) {
221-
background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0NDggNTEyIj48IS0tIUZvbnQgQXdlc29tZSBGcmVlIDYuNy4yIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlL2ZyZWUgQ29weXJpZ2h0IDIwMjUgRm9udGljb25zLCBJbmMuLS0+PHBhdGggZmlsbD0id2hpdGUiIGQ9Ik0yMDEuNCAzNzQuNmMxMi41IDEyLjUgMzIuOCAxMi41IDQ1LjMgMGwxNjAtMTYwYzEyLjUtMTIuNSAxMi41LTMyLjggMC00NS4zcy0zMi44LTEyLjUtNDUuMyAwTDIyNCAzMDYuNyA4Ni42IDE2OS40Yy0xMi41LTEyLjUtMzIuOC0xMi41LTQ1LjMgMHMtMTIuNSAzMi44IDAgNDUuM2wxNjAgMTYweiIvPjwvc3ZnPg==');
228+
background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0NDggNTEyIj48IS0tIUZvbnQgQXdlc29tZSBGcmVlIDYuNy4yIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlL2ZyZWUgQ29weXJpZ2h0IDIwMjUgRm9udGljb25zLCBJbmMuLS0+PHBhdGggZmlsbD0id2hpdGUiIGQ9Ik0yMDEuNCAzNzQuNmMxMi41IDEyLjUgMzIuOCAxMi41IDQ1LjMgMGwxNjAtMTYwYzEyLjUtMTIuNSAxMi41LTMyLjggMC00NS4zcy0zMi44LTEyLjUtNDUuMyAwTDIyNCAzMDYuNyA4Ni42IDE2OS40Yy0xMi41LTEyLjUtMzIuOC0xMi41LTQ1LjMgMHMtMTIuNSAzMi44IDAgNDUuM2wxNjAgMTYweiIvPjwvc3ZnPg==");
222229
background-position: center center;
223230
background-repeat: no-repeat;
224-
content: '';
231+
content: "";
225232
height: variables.space(4);
226233
transition-duration: 150ms;
227234
transition-property: rotate;

0 commit comments

Comments
 (0)