Skip to content
This repository was archived by the owner on Oct 1, 2021. It is now read-only.

Commit a8dc3a6

Browse files
committed
feat(header): add burger menu
1 parent a5eee88 commit a8dc3a6

File tree

1 file changed

+104
-25
lines changed

1 file changed

+104
-25
lines changed

src/src/components/AppHeader.vue

Lines changed: 104 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
<template>
2-
<header>
2+
<header :class="{ active: menuIsActive }">
33
<div class="container">
44
<button class="link logo" @click="scrollToTop">StyleBase</button>
5+
<button class="link burger-menu" @click="menuIsActive = !menuIsActive">
6+
<span></span>
7+
<span></span>
8+
</button>
59
<nav>
610
<button class="link" type="button" @click="$emit('open-nav-link', 'showHowtoUseModal')">How to Use</button>
711
<button class="link" type="button" @click="$emit('open-nav-link', 'showAddStyleModal')">Add Style</button>
@@ -13,6 +17,11 @@
1317
<script>
1418
export default {
1519
name: 'AppHeader',
20+
data() {
21+
return {
22+
menuIsActive: false
23+
};
24+
},
1625
methods: {
1726
scrollToTop() {
1827
window.scroll({ top: 0, left: 0, behavior: 'smooth' });
@@ -29,49 +38,119 @@ header {
2938
background-color: var(--color-bg);
3039
3140
.container {
41+
position: relative;
3242
display: flex;
43+
flex-wrap: wrap;
3344
align-items: center;
3445
justify-content: space-between;
3546
padding-top: 1rem;
3647
padding-bottom: 1rem;
48+
}
49+
50+
button,
51+
a {
52+
outline: 0;
53+
border-radius: 0;
54+
border-bottom: 2px solid transparent;
55+
font-size: 18px;
56+
57+
&:focus {
58+
border-color: var(--color-focus);
59+
}
60+
}
61+
62+
.logo {
63+
font-size: 28px;
64+
font-weight: bold;
65+
}
3766
38-
button,
39-
a {
40-
border-radius: 0;
41-
outline: 0;
42-
border-bottom: 2px solid transparent;
67+
.burger-menu {
68+
display: none;
69+
position: relative;
70+
width: 2rem;
71+
height: 2rem;
4372
44-
&:focus {
45-
border-color: var(--color-focus);
73+
@include media-size-mobile {
74+
display: inline-block;
75+
}
76+
77+
span {
78+
position: absolute;
79+
left: 0;
80+
width: 100%;
81+
height: 2px;
82+
background-color: var(--color-text);
83+
transition: transform 0.3s;
84+
85+
&:nth-child(1) {
86+
top: 10px;
87+
}
88+
&:nth-child(2) {
89+
bottom: 10px;
4690
}
4791
}
4892
49-
.logo {
50-
font-size: 28px;
51-
font-weight: bold;
93+
&:focus {
94+
border-color: transparent;
5295
53-
@include media-size-mobile {
54-
font-size: 24px;
96+
span {
97+
background-color: var(--color-focus);
5598
}
5699
}
100+
}
57101
58-
nav {
59-
button {
60-
font-size: 18px;
102+
nav {
103+
button {
104+
margin-left: 1.5rem;
105+
}
61106
62-
@include media-size-mobile {
63-
font-size: 16px;
64-
}
107+
@include media-size-mobile {
108+
display: flex;
109+
flex-basis: 100%;
110+
flex-direction: column;
111+
align-items: flex-start;
112+
background-color: var(--color-bg);
113+
animation: slide-in 0.5s forwards;
114+
overflow: hidden;
65115
66-
&:not(:last-child) {
67-
margin-right: 1.5rem;
116+
button {
117+
margin-top: 0.75rem;
118+
margin-left: 0rem;
119+
}
120+
}
121+
}
68122
69-
@include media-size-mobile {
70-
margin-right: 0.5rem;
71-
}
72-
}
123+
&.active {
124+
.burger-menu span {
125+
top: 13px;
126+
127+
&:nth-child(1) {
128+
transform: rotate(45deg);
129+
}
130+
&:nth-child(2) {
131+
transform: rotate(-45deg);
73132
}
74133
}
134+
135+
nav {
136+
animation: slide-out 0.5s forwards;
137+
}
138+
}
139+
@keyframes slide-out {
140+
from {
141+
max-height: 0;
142+
}
143+
to {
144+
max-height: 5rem;
145+
}
146+
}
147+
@keyframes slide-in {
148+
from {
149+
max-height: 5rem;
150+
}
151+
to {
152+
max-height: 0;
153+
}
75154
}
76155
}
77156
</style>

0 commit comments

Comments
 (0)