Skip to content

Commit a446d02

Browse files
authored
update: nav — new container and section (#286)
update: `nav` — new container and section
2 parents 1e3139b + e978b2a commit a446d02

File tree

2 files changed

+65
-26
lines changed

2 files changed

+65
-26
lines changed

src/_includes/components/nav.njk

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
<nav class="nav t-all">
2+
<div class="nav-skip">
3+
<a class="nav-skipto" href="#main">Skip to Main</a>
4+
</div>
25
<div class="nav-container">
36
<div class="leftside">
4-
<a class="nav-skipto" href="#main">Skip to Main</a>
5-
<a class="brand" aria-labelledby="emptywork-logo-text" href="{{ link.website | development }}">
7+
<a class="brand"
8+
aria-labelledby="emptywork-logo-text"
9+
href="{{ link.website | development }}">
610
<div class="brand-logo">
711
{{ footer.brand.svg | svg | safe }}
812
<span aria-hidden="true" id="emptywork-logo-text" class="sr-only">Logo of EmptyWork</span>
@@ -22,41 +26,59 @@
2226
</ul>
2327
<div class="rightside">
2428
<button class="themes" aria-label="Switch the theme" data-theme-button>
25-
<svg data-sun fill="none" style="margin-bottom: -0.0625rem" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-label="Icon of sun">
26-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"></path>
29+
<svg data-sun
30+
fill="none"
31+
style="margin-bottom: -0.0625rem"
32+
stroke="currentColor"
33+
viewBox="0 0 24 24"
34+
xmlns="http://www.w3.org/2000/svg"
35+
aria-label="Icon of sun">
36+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z">
37+
</path>
2738
</svg>
28-
<svg data-moon fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" aria-label="Icon of moon">
39+
<svg data-moon
40+
fill="currentColor"
41+
viewBox="0 0 20 20"
42+
xmlns="http://www.w3.org/2000/svg"
43+
aria-label="Icon of moon">
2944
<path d="M17.293 13.293A8 8 0 016.707 2.707a8.001 8.001 0 1010.586 10.586z"></path>
3045
</svg>
3146
</button>
32-
<button aria-label="Open the mobile menu" aria-haspopup="true" aria-controls="mobile-menu-list" class="nav-mobile nav-mobile__tick" data-mobile-menu-button>
33-
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-label="Icon for menu hamburger">
47+
<button aria-label="Open the mobile menu"
48+
aria-haspopup="true"
49+
aria-controls="mobile-menu-list"
50+
class="nav-mobile nav-mobile__tick"
51+
data-mobile-menu-button>
52+
<svg fill="none"
53+
stroke="currentColor"
54+
viewBox="0 0 24 24"
55+
xmlns="http://www.w3.org/2000/svg"
56+
aria-label="Icon for menu hamburger">
3457
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"></path>
3558
</svg>
3659
</button>
3760
</div>
3861
</div>
3962
</nav>
40-
<ul id="mobile-menu-list" class="not-showing nav-mobile__section t-all" data-mobile-menu-section aria-label="List of mobile menu" role="menu">
63+
<ul id="mobile-menu-list"
64+
class="not-showing nav-mobile__section t-all"
65+
data-mobile-menu-section
66+
aria-label="List of mobile menu"
67+
aria-hidden="true"
68+
role="menu">
4169
<li data-mobile-menu-button role="menuitem">
4270
<a href="/">
43-
<div>
44-
Home
45-
</div>
71+
<div>Home</div>
4672
</a>
4773
</li>
4874
<li data-mobile-menu-button role="menuitem">
4975
<a href="/blog">
50-
<div>
51-
Blog
52-
</div>
76+
<div>Blog</div>
5377
</a>
5478
</li>
5579
<li data-mobile-menu-button role="menuitem">
5680
<a href="/contact">
57-
<div>
58-
Contact
59-
</div>
81+
<div>Contact</div>
6082
</a>
6183
</li>
62-
</ul>
84+
</ul>

src/assets/scss/components/_nav.scss

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,22 @@
66
flex-shrink: 0;
77
position: sticky;
88
top: 0;
9-
padding: 0.8rem;
109
z-index: 20;
1110

11+
&-skip {
12+
position: relative;
13+
width: 100%;
14+
height: 0;
15+
transition: height 200ms ease;
16+
justify-content: center;
17+
18+
&:has(:focus) {
19+
height: calc(1em + 0.6em);
20+
}
21+
}
22+
1223
&-container {
24+
padding: 0.8rem;
1325
width: 100%;
1426
max-width: 64rem;
1527
margin: 0 auto;
@@ -29,17 +41,22 @@
2941
&-skipto {
3042
background-color: var(--clr-accent);
3143
color: var(--clr-white);
32-
display: flex;
3344
padding: 0 0.3rem;
34-
align-self: center;
35-
scale: 0 1;
36-
order: 2;
37-
transform-origin: left;
38-
transition: scale 200ms ease;
45+
position: absolute !important;
46+
left: 0;
47+
right: 0;
48+
top: 0;
49+
width: 100%;
50+
height: max-content;
51+
text-align: center;
52+
opacity: 0;
53+
transition: opacity 200ms ease;
54+
pointer-events: none;
3955

4056
&:focus {
57+
pointer-events: unset;
58+
opacity: 1;
4159
color: var(--clr-white);
42-
scale: 1;
4360
}
4461
}
4562

0 commit comments

Comments
 (0)