File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11---
2- import Navigation from ' ../components/Navigation.astro' ;
2+ import Navigation from ' ./Navigation.astro' ;
3+ import Menu from ' ./Menu.astro' ;
34---
45
56<header >
67 <nav >
8+ <Menu />
79 <Navigation />
810 </nav >
911</header >
Original file line number Diff line number Diff line change 1+ ---
2+ ---
3+ <button aria-expanded =" false" aria-controls =" main-menu" class =" menu" >
4+ Menu
5+ </button >
Original file line number Diff line number Diff line change @@ -69,5 +69,10 @@ const skillColor = "crimson";
6969 { skills .map ((skill ) => <li class = " skill" >{ skill } </li >)}
7070 </ul >
7171 <Footer />
72+
73+ <script >
74+ import "../scripts/menu.js";
75+ </script >
76+
7277 </body >
7378</html >
Original file line number Diff line number Diff line change @@ -26,5 +26,10 @@ const pgTitle = "My Astro Learning Blog";
2626 <a href =" /myAstroTest/posts/post-3" >Post 3</a >
2727 </ul >
2828 <Footer />
29+
30+ <script >
31+ import "../scripts/menu.js";
32+ </script >
33+
2934 </body >
3035</html >
Original file line number Diff line number Diff line change @@ -28,5 +28,11 @@ const pgTitle = "My Astro Website Deployed with an Action";
2828 <Header />
2929 <h1 >{ pgTitle } </h1 >
3030 <Footer />
31+
32+ <script >
33+ import "../scripts/menu.js";
34+ </script >
35+
36+
3137 </body >
3238</html >
Original file line number Diff line number Diff line change 1+ const menu = document . querySelector ( '.menu' ) ;
2+
3+ menu ?. addEventListener ( 'click' , ( ) => {
4+ const isExpanded = menu . getAttribute ( 'aria-expanded' ) === 'true' ;
5+ menu . setAttribute ( 'aria-expanded' , `${ ! isExpanded } ` ) ;
6+ } ) ;
Original file line number Diff line number Diff line change 2020 font-size : 2.5rem ;
2121}
2222
23+ /* Menu */
24+
25+ .menu {
26+ background-color : # 0d0950 ;
27+ border : none;
28+ color : # fff ;
29+ font-size : 1.2rem ;
30+ font-weight : bold;
31+ padding : 5px 10px ;
32+ }
33+
2334/* nav styles */
2435
2536.nav-links {
4455 background-color : # ff9776 ;
4556}
4657
58+ : has (.menu [aria-expanded = "true" ]) .nav-links {
59+ display : unset;
60+ }
61+
4762@media screen and (min-width : 636px ) {
4863 .nav-links {
4964 margin-left : 5em ;
5772 display : inline-block;
5873 padding : 15px 20px ;
5974 }
75+
76+ .menu {
77+ display : none;
78+ }
79+
6080}
You can’t perform that action at this time.
0 commit comments