Skip to content

Commit 62f482d

Browse files
authored
Merge pull request #50 from heem42/feat/hamburger-menu
Feature: hamburger menu
2 parents 31be301 + 737a066 commit 62f482d

File tree

3 files changed

+115
-17
lines changed

3 files changed

+115
-17
lines changed

src/components/PostHeader/index.astro

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
import { Image } from 'astro:assets';
32
import { Icon } from 'astro-icon/components';
3+
import { Image } from 'astro:assets';
44
55
import { getFormattedAuthorsList } from '../../utils/post';
66
import SiteNav from '../SiteNav/index.astro';

src/components/SiteNav/index.astro

+53-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
---
2+
import { Icon } from 'astro-icon/components';
23
import { Image } from 'astro:assets';
34
import logo from '../../assets/icons/logo.svg';
45
import './styles.css';
56
const BLOG_URL = Astro.site?.href;
67
---
7-
<nav id="site-nav">
8-
<ul>
8+
9+
<nav id="desktop-navigation" aria-label="Main blog navigation">
10+
<ul class="nav-links">
911
<li>
1012
<a href={BLOG_URL}>
11-
<Image src={logo} alt="TorontoJS Logo!" height={70} width={70} id="logo-rounded" />
12-
</a>
13-
</li>
14-
<li>
15-
<a href={`${BLOG_URL}about`}>
16-
About
13+
<Image src={logo} class="logo-rounded" alt="TorontoJS Logo!" height={70} width={70} />
1714
</a>
1815
</li>
1916
<li>
@@ -26,5 +23,53 @@ const BLOG_URL = Astro.site?.href;
2623
License
2724
</a>
2825
</li>
26+
<li>
27+
<a href={`${BLOG_URL}about`}>
28+
About
29+
</a>
30+
</li>
2931
</ul>
3032
</nav>
33+
34+
<div id="mobile-navigation">
35+
<a id="mobile-logo" href={BLOG_URL}>
36+
<Image src={logo} alt="TorontoJS Logo!" height={70} width={70} class="logo-rounded" />
37+
</a>
38+
<button
39+
id="hamburger-button" aria-controls="mobile-menu" aria-expanded="false" aria-haspopup="true"
40+
aria-label="Open blog navigation" popovertarget="mobile-menu"
41+
>
42+
<Icon
43+
id="hamburger-icon" name="mdi:hamburger-menu" title="Hamburger Menu Icon" width={70} height={70}
44+
/>
45+
</button>
46+
<nav popover id="mobile-menu" aria-label="Main blog navigation">
47+
<button popovertarget="mobile-menu" aria-controls="mobile-menu" aria-label="Close blog navigation">
48+
<Icon
49+
id="close-icon" name="mdi:close" title="Close Icon" width={70} height={70}
50+
/>
51+
</button>
52+
<ul class="nav-links">
53+
<li>
54+
<a href={BLOG_URL}>
55+
<Image src={logo} alt="TorontoJS Logo!" height={70} width={70} class="logo-rounded" />
56+
</a>
57+
</li>
58+
<li>
59+
<a href={`${BLOG_URL}accessibility`}>
60+
Accessibility
61+
</a>
62+
</li>
63+
<li>
64+
<a href={`${BLOG_URL}license`}>
65+
License
66+
</a>
67+
</li>
68+
<li>
69+
<a href={`${BLOG_URL}about`}>
70+
About
71+
</a>
72+
</li>
73+
</ul>
74+
</nav>
75+
</div>

src/components/SiteNav/styles.css

+61-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,74 @@
1-
#site-nav {
2-
padding: var(--size-2);
1+
#desktop-navigation, #mobile-navigation {
32
background-color: var(--tjs-dark-bg);
43
font-weight: bold;
4+
padding: var(--size-2);
55
}
66

7-
#site-nav ul {
7+
.nav-links {
88
gap: var(--size-2);
99
align-items: center;
10-
padding: var(--size-3);
10+
list-style: none;
11+
display: flex;
12+
padding: var(--size-3)
1113
}
1214

13-
#site-nav a { color: white; }
15+
.nav-links a {
16+
color: white;
17+
}
1418

15-
#logo-rounded {
19+
.logo-rounded {
1620
border-radius: var(--size-2);
1721
}
1822

19-
@media (max-width: 500px) {
20-
#site-nav ul { flex-direction: column; }
23+
#hamburger-button {
24+
background-color: transparent;
25+
padding: var(--size-3)
26+
}
27+
28+
#mobile-navigation {
29+
display: none;
30+
}
31+
32+
#mobile-menu:popover-open {
33+
width: 100%;
34+
height: 100%;
35+
text-align: center;
36+
display: flex;
37+
flex-direction: column;
38+
padding: var(--size-3)
39+
}
40+
41+
#mobile-menu:popover-open ul {
42+
display: flex;
43+
flex-direction: column;
44+
padding: var(--size-2);
45+
}
46+
47+
#mobile-menu:popover-open button {
48+
background-color: transparent;
49+
margin-left: auto;
50+
padding: var(--size-2);
51+
}
52+
53+
#mobile-logo {
54+
align-content: center;
55+
padding: var(--size-3);
56+
}
57+
58+
@media (max-width: 32rem) {
59+
#mobile-navigation {
60+
display: flex;
61+
justify-content: space-between;
62+
text-align: right;
63+
}
64+
65+
#desktop-navigation {
66+
display: none;
67+
}
68+
}
69+
70+
@media (max-width: 32rem) {
71+
.nav-links {
72+
flex-direction: column;
73+
}
2174
}

0 commit comments

Comments
 (0)