Skip to content

Commit 861a2ef

Browse files
committed
Animate menu button
1 parent ef38bc6 commit 861a2ef

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/components/page/header.astro

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,14 @@ import {
121121
const menuButton = document.getElementById(menuButtonId) as HTMLButtonElement;
122122
const modeButton = document.getElementById(modeButtonId) as HTMLButtonElement;
123123

124+
menuButton.classList.add("transition-transform");
124125
menuButton.addEventListener("click", () => {
125126
document.body.classList.toggle("open-nav");
126127
header.classList.toggle("open-nav");
127128
navList.classList.toggle("open-nav");
128129
modeButton.classList.toggle("open-nav");
130+
131+
menuButton.classList.toggle("rotate-left");
129132
});
130133

131134
const darkModeMedia = matchMedia("(prefers-color-scheme: dark)");

src/styles/header.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
gap: v-size(5);
4242
justify-items: center;
4343
margin-bottom: v-size(10);
44-
overflow: auto;
44+
overflow: hidden auto;
4545
}
4646
.logo {
4747
justify-self: start;

src/styles/page.scss

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ p.larger-spacing {
145145

146146
// Animations
147147

148+
.rotate-left {
149+
transform: rotateZ(-90deg);
150+
}
148151
.rotate-appear {
149152
animation: 0ms ease-in-out forwards rotate-appear;
150153
}
@@ -153,9 +156,10 @@ p.larger-spacing {
153156
}
154157

155158
@include m-motion {
156-
.rotate-appear {
157-
animation-duration: 250ms;
159+
.transition-transform {
160+
transition: transform 250ms ease-in-out;
158161
}
162+
.rotate-appear,
159163
.rotate-vanish {
160164
animation-duration: 250ms;
161165
}

0 commit comments

Comments
 (0)