Skip to content

Commit 3d4a0e4

Browse files
committed
style: hamburger
1 parent 7a78766 commit 3d4a0e4

File tree

1 file changed

+64
-72
lines changed

1 file changed

+64
-72
lines changed

src/App.vue

Lines changed: 64 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
<template>
22
<div class="app">
33
<!-- HEADER -->
4-
<header class="site-header">
4+
<transition name="menu-fade">
5+
<header class="site-header" :class="{ 'is-open': isOpen }">
56
<div class="container header-inner">
6-
<div class="brand">
7+
<div class="brand" :class="{ 'is-open': isOpen }">
78
<a href="/">
89
<img :src="Logo" alt="Logo" class="brand-logo"/>
910
<span class="brand-title">TheCode</span>
1011
</a>
1112
</div>
1213

13-
<div class="hamburger-menu">
14-
<button class="hamburger" @click="toggleMenu">&#9776;</button>
15-
<transition name="menu-fade">
16-
<div v-if="isOpen" class="mobile-nav">
17-
<button class="hamburger close-btn" @click="closeMenu">✕</button>
18-
<nav aria-label="Phone Navigation">
14+
<nav aria-label="large nav" class="large_nav">
15+
<router-link to="/" exact @click="closeMenu">Accueil</router-link>
16+
<router-link to="/generate" @click="closeMenu">Générateur</router-link>
17+
<router-link to="/privacy" @click="closeMenu">Confidentialité</router-link>
18+
</nav>
19+
20+
21+
<div class="hamburger-menu">
22+
<div v-if="isOpen">
23+
<nav aria-label="small nav" class="small_nav">
1924
<router-link to="/" exact @click="closeMenu">Accueil</router-link>
2025
<router-link to="/generate" @click="closeMenu">Générateur</router-link>
2126
<router-link to="/privacy" @click="closeMenu">Confidentialité</router-link>
2227
</nav>
2328
</div>
24-
</transition>
25-
<div class="nav">
26-
<nav aria-label="Big Navigation">
27-
<router-link to="/" exact @click="closeMenu">Accueil</router-link>
28-
<router-link to="/generate" @click="closeMenu">Générateur</router-link>
29-
<router-link to="/privacy" @click="closeMenu">Confidentialité</router-link>
30-
</nav>
29+
<button v-if="!isOpen" id="open-btn" @click="toggleMenu">&#9776;</button>
30+
<button v-if="isOpen" id="close-btn" @click="closeMenu">✕</button>
3131
</div>
32-
</div>
3332
</div>
3433
</header>
34+
</transition>
3535

3636
<!-- MAIN CONTENT -->
3737
<main class="main">
@@ -96,6 +96,10 @@ export default defineComponent({
9696
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
9797
backdrop-filter: saturate(180%) blur(20px);
9898
-webkit-backdrop-filter: saturate(180%) blur(20px);
99+
transition: max-height 0.4s ease, opacity 0.4s ease;
100+
max-height: 25px;
101+
height: 100vh;
102+
overflow: hidden;
99103
}
100104
101105
.container {
@@ -139,121 +143,109 @@ export default defineComponent({
139143
margin: auto auto auto 20px;
140144
}
141145
142-
.nav a {
146+
.large_nav a {
143147
margin-left: 25px;
144148
text-decoration: none;
145149
font-weight: 500;
146150
padding-bottom: 4px;
147151
color: black;
148152
}
149153
150-
.nav a:hover {
154+
.large_nav a:hover, .small_nav a:hover {
151155
color: #6A1E55;
152156
}
153157
154-
.nav .router-link-exact-active {
158+
.large_nav .router-link-exact-active, .small_nav .router-link-exact-active {
155159
font-weight: bold;
156160
}
157161
158-
.main {
159-
flex: 1;
160-
display: flex;
161-
flex-direction: column;
162-
}
163-
164-
.site-footer {
165-
background: var(--c2);
166-
text-align: center;
167-
padding: 15px 0;
168-
font-size: 0.85rem;
169-
color: #ddd;
170-
border-top: 1px solid rgba(255, 255, 255, 0.05);
171-
}
172-
173-
.hamburger {
174-
display: none;
175-
}
176-
177-
.mobile-nav {
178-
display: none;
179-
position: fixed;
180-
top: 0;
162+
.small_nav {
163+
position: absolute;
164+
display: grid;
181165
left: 0;
166+
top: 50px;
182167
width: 100vw;
183-
height: 100vh;
184-
background: rgba(245, 245, 247, 1);
185-
flex-direction: column;
186-
align-items: center;
187-
justify-content: center;
188-
gap: 30px;
189-
z-index: 2000;
190-
transform: translateY(0);
191168
}
192169
193-
.mobile-nav nav {
170+
.small_nav nav {
194171
display: flex;
195172
flex-direction: column;
196173
gap: 20px;
197174
width: 100%;
198175
padding: 20px;
199176
}
200177
201-
.mobile-nav a {
178+
.small_nav a {
179+
margin: 20px;
180+
padding: 10px 0;
202181
color: var(--text);
203182
font-size: 1.5rem;
204183
text-decoration: none;
205-
margin: 20px;
206184
font-weight: 400;
207-
transition: color 0.2s, font-weight 0.4s;
185+
transition: color 0.4s;
208186
}
209187
210-
.mobile-nav a:hover {
211-
color: #6A1E55;
212-
font-weight: 700;
188+
.main {
189+
flex: 1;
190+
display: flex;
191+
flex-direction: column;
192+
}
193+
194+
.site-footer {
195+
background: var(--c2);
196+
text-align: center;
197+
padding: 15px 0;
198+
font-size: 0.85rem;
199+
color: #ddd;
200+
border-top: 1px solid rgba(255, 255, 255, 0.05);
213201
}
214202
215-
.close-btn {
203+
button {
216204
position: absolute;
217-
top: 20px;
205+
top: 10px;
218206
right: 25px;
219207
background: none;
220208
border: none;
221209
font-size: 2rem;
222210
color: var(--text);
223211
cursor: pointer;
212+
display: none;
213+
}
214+
215+
.hamburger-menu {
216+
display: none;
224217
}
225218
226219
/* TRANSITION ANIMATION */
227220
.menu-fade-enter-active,
228221
.menu-fade-leave-active {
229222
transition: opacity 0.4s ease;
230223
}
224+
231225
.menu-fade-enter-from,
232226
.menu-fade-leave-to {
233227
opacity: 0;
234228
}
235229
236230
@media (max-width: 550px) {
231+
.site-header.is-open {
232+
max-height: 100vh;
233+
}
234+
235+
.large_nav {
236+
display: none;
237+
}
238+
237239
.hamburger-menu {
238-
position: relative;
239-
display: inline-block;
240+
display: flex;
240241
}
241242
242-
.hamburger {
243-
font-size: 2rem;
244-
background: none;
245-
border: none;
246-
color: var(--c3);
247-
cursor: pointer;
243+
button {
248244
display: block;
249245
}
250246
251-
.nav {
247+
.brand:is(.is-open) {
252248
display: none;
253249
}
254-
255-
.mobile-nav {
256-
display: flex;
257-
}
258250
}
259251
</style>

0 commit comments

Comments
 (0)