1
1
<template >
2
- <header >
2
+ <header :class = " { active: menuIsActive } " >
3
3
<div class =" container" >
4
4
<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 >
5
9
<nav >
6
10
<button class =" link" type =" button" @click =" $emit('open-nav-link', 'showHowtoUseModal')" >How to Use</button >
7
11
<button class =" link" type =" button" @click =" $emit('open-nav-link', 'showAddStyleModal')" >Add Style</button >
13
17
<script >
14
18
export default {
15
19
name: ' AppHeader' ,
20
+ data () {
21
+ return {
22
+ menuIsActive: false
23
+ };
24
+ },
16
25
methods: {
17
26
scrollToTop () {
18
27
window .scroll ({ top: 0 , left: 0 , behavior: ' smooth' });
@@ -29,49 +38,119 @@ header {
29
38
background-color : var (--color-bg );
30
39
31
40
.container {
41
+ position : relative ;
32
42
display : flex ;
43
+ flex-wrap : wrap ;
33
44
align-items : center ;
34
45
justify-content : space-between ;
35
46
padding-top : 1rem ;
36
47
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
+ }
37
66
38
- button ,
39
- a {
40
- border-radius : 0 ;
41
- outline : 0 ;
42
- border-bottom : 2 px solid transparent ;
67
+ .burger-menu {
68
+ display : none ;
69
+ position : relative ;
70
+ width : 2 rem ;
71
+ height : 2 rem ;
43
72
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 ;
46
90
}
47
91
}
48
92
49
- .logo {
50
- font-size : 28px ;
51
- font-weight : bold ;
93
+ & :focus {
94
+ border-color : transparent ;
52
95
53
- @include media-size-mobile {
54
- font-size : 24 px ;
96
+ span {
97
+ background-color : var ( --color-focus ) ;
55
98
}
56
99
}
100
+ }
57
101
58
- nav {
59
- button {
60
- font-size : 18px ;
102
+ nav {
103
+ button {
104
+ margin-left : 1.5rem ;
105
+ }
61
106
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 ;
65
115
66
- & :not (:last-child ) {
67
- margin-right : 1.5rem ;
116
+ button {
117
+ margin-top : 0.75rem ;
118
+ margin-left : 0rem ;
119
+ }
120
+ }
121
+ }
68
122
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 );
73
132
}
74
133
}
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
+ }
75
154
}
76
155
}
77
156
</style >
0 commit comments