@@ -5,34 +5,40 @@ import PageLink from "./PageLink.astro";
55---
66
77<div id =" mobile-header" class =" header" >
8- <div id =" mobile-nav-dropdown" class =" dropdown" >
9- <i id =" burger-menu-icon" class =" fa-solid fa-bars" ></i >
10- <div class =" dropdown-items" >
11- <nav class =" dropdown-item" >
12- { PAGES .map ((pageProps ) => <PageLink { ... pageProps } />)}
13- </nav >
14- <div id =" theme-row" class =" dropdown-item" >
15- <label for =" theme" >Theme:</label >
16- <select name =" theme" id =" theme-select" >
17- {
18- themes .map (({ name , theme }) => (
19- <option value = { theme } >{ name } </option >
20- ))
21- }
22- </select >
23- </div >
8+ <i id =" burger-menu-icon" class =" fa-solid fa-bars" ></i >
9+ <div id =" sidebar" >
10+ <nav class =" dropdown-item" >
11+ { PAGES .map ((pageProps ) => <PageLink { ... pageProps } />)}
12+ </nav >
13+ <div id =" theme-row" class =" dropdown-item" >
14+ <label for =" theme" >Theme:</label >
15+ <select name =" theme" id =" theme-select" >
16+ { themes .map (({ name , theme }) => <option value = { theme } >{ name } </option >)}
17+ </select >
2418 </div >
2519 </div >
2620</div >
2721
2822<script >
2923 import { setTheme } from "../../../theme";
3024
31- const dropdown = document.getElementById("mobile-nav-dropdown ")!;
25+ const sidebar = document.getElementById("sidebar ")!;
3226 const burgerIcon = document.getElementById("burger-menu-icon")!;
33- burgerIcon.addEventListener("click", () =>
34- dropdown.classList.toggle("active"),
35- );
27+ burgerIcon.addEventListener("click", () => {
28+ sidebar.classList.toggle("active");
29+ if (burgerIcon.classList.contains("fa-bars")) {
30+ burgerIcon.classList.replace("fa-bars", "fa-xmark");
31+ } else {
32+ burgerIcon.classList.replace("fa-xmark", "fa-bars");
33+ }
34+
35+ if (sidebar.classList.contains("active")) {
36+ // Defined in common.scss
37+ document.body.classList.add("disable-scroll");
38+ } else {
39+ document.body.classList.remove("disable-scroll");
40+ }
41+ });
3642
3743 document
3844 .getElementById("theme-select")!
@@ -55,26 +61,45 @@ import PageLink from "./PageLink.astro";
5561 margin-left: auto;
5662 }
5763
58- .dropdown-items {
59- background-color: var(--bg-color);
60- padding-top: 15px;
61- background-clip: padding-box;
64+ #burger-menu-icon {
65+ z-index: 1000;
66+ position: relative;
6267 }
6368
64- .dropdown-item {
65- background-color: var(--bg-hoverable);
66- padding-left: 15px;
67- padding-right: 15px
69+ #sidebar {
70+ z-index: 100;
71+ position: fixed;
72+ top: 0;
73+ height: 100vh;
74+ width: 100vw;
75+ padding-top: 4rem;
76+
77+ background-color: var(--bg-color);
78+
79+ left: 100vw;
80+ transition: left 0.5s;
81+
82+ &.active {
83+ left: 0;
84+ transition: left 0.5s;
85+ }
6886 }
6987
7088 nav {
7189 display: flex;
7290 flex-direction: column;
73- padding-top: 15px;
74- padding-bottom: 10px;
91+ padding-top: 3rem;
92+ padding-bottom: 4rem;
93+ gap: 0.75rem;
94+
95+ width: min-content;
96+ margin-left: auto;
97+ margin-right: auto;
7598 }
7699
77100 #theme-row {
78- padding-bottom: 15px;
101+ width: min-content;
102+ margin-left: auto;
103+ margin-right: auto;
79104 }
80105</style >
0 commit comments