Skip to content
This repository was archived by the owner on Apr 19, 2023. It is now read-only.

Commit 89d1e27

Browse files
✨ Add transition for dropdowns
1 parent 33e39df commit 89d1e27

File tree

2 files changed

+61
-47
lines changed

2 files changed

+61
-47
lines changed

components/Navbar.vue

Lines changed: 59 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -14,56 +14,56 @@
1414
<button
1515
class="item item--type-less"
1616
to="/settings/account"
17+
aria-label="Help"
18+
data-balloon="Help"
19+
data-balloon-pos="down"
1720
aria-controls="help"
1821
:aria-expanded="(visible === 'help').toString()"
1922
>
2023
<font-awesome-icon
21-
title="Help"
2224
class="nav-icon"
2325
icon="question-circle"
2426
fixed-width
2527
/>
2628
</button>
27-
<div
28-
ref="dropdown-help"
29-
id="help"
30-
:class="
31-
`dropdown${visible === 'help' ? ' dropdown--state-visible' : ''}`
32-
"
33-
>
34-
<nuxt-link class="item" to="/settings">Feedback</nuxt-link>
35-
<nuxt-link class="item" to="/settings/account"
36-
>Help Center</nuxt-link
29+
<transition name="dropdown-fade">
30+
<div
31+
v-show="visible === 'help'"
32+
id="help"
33+
ref="dropdown-help"
34+
class="dropdown"
3735
>
38-
<button class="item">Accessibility</button>
39-
</div>
36+
<nuxt-link class="item" to="/settings">Feedback</nuxt-link>
37+
<nuxt-link class="item" to="/settings/account"
38+
>Help Center</nuxt-link
39+
>
40+
<button class="item">Accessibility</button>
41+
</div>
42+
</transition>
4043
</span>
4144
<span>
4245
<button
4346
class="item item--type-less item--type-last"
4447
to="/settings/notifications"
48+
aria-label="Notifications"
49+
data-balloon="Notifications"
50+
data-balloon-pos="down"
4551
aria-controls="notifications"
4652
:aria-expanded="(visible === 'notifications').toString()"
4753
>
48-
<font-awesome-icon
49-
title="Notifications"
50-
class="nav-icon"
51-
icon="bell"
52-
fixed-width
53-
/>
54+
<font-awesome-icon class="nav-icon" icon="bell" fixed-width />
5455
</button>
55-
<div
56-
ref="dropdown-notifications"
57-
id="notifications"
58-
:class="
59-
`dropdown${
60-
visible === 'notifications' ? ' dropdown--state-visible' : ''
61-
}`
62-
"
63-
style="width: 350px"
64-
>
65-
<Notifications />
66-
</div>
56+
<transition name="dropdown-fade">
57+
<div
58+
v-show="visible === 'notifications'"
59+
id="notifications"
60+
ref="dropdown-notifications"
61+
class="dropdown"
62+
style="width: 350px"
63+
>
64+
<Notifications />
65+
</div>
66+
</transition>
6767
</span>
6868
<span>
6969
<button
@@ -75,21 +75,22 @@
7575
<img alt="" :src="user.profilePicture" />
7676
{{ user.nickname }}
7777
</button>
78-
<div
79-
ref="dropdown-account"
80-
id="account"
81-
:class="
82-
`dropdown${
83-
visible === 'account' ? ' dropdown--state-visible' : ''
84-
}`
85-
"
86-
>
87-
<nuxt-link class="item" to="/settings/account">Settings</nuxt-link>
88-
<nuxt-link class="item" to="/settings/organizations"
89-
>Organizations</nuxt-link
78+
<transition name="dropdown-fade">
79+
<div
80+
v-show="visible === 'account'"
81+
id="account"
82+
ref="dropdown-account"
83+
class="dropdown"
9084
>
91-
<button class="item" @click="logout">Logout</button>
92-
</div>
85+
<nuxt-link class="item" to="/settings/account"
86+
>Settings</nuxt-link
87+
>
88+
<nuxt-link class="item" to="/settings/organizations"
89+
>Organizations</nuxt-link
90+
>
91+
<button class="item" @click="logout">Logout</button>
92+
</div>
93+
</transition>
9394
</span>
9495
</nav>
9596
<nav v-else>
@@ -233,7 +234,7 @@ nav .button {
233234
z-index: 1;
234235
}
235236
}
236-
.dropdown--state-visible {
237+
.dropdown {
237238
display: block;
238239
}
239240
.dropdown .item {
@@ -257,4 +258,16 @@ nav .item.item--type-user {
257258
opacity: 0.7;
258259
transform: scale(1.1);
259260
}
261+
nav .item.item--type-less:hover {
262+
opacity: 1;
263+
}
264+
.dropdown-fade-enter-active,
265+
.dropdown-fade-leave-active {
266+
transition: opacity 0.2s, margin-top 0.45s;
267+
}
268+
.dropdown-fade-enter,
269+
.dropdown-fade-leave-to {
270+
opacity: 0;
271+
margin-top: -0.5rem;
272+
}
260273
</style>

layouts/default.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@ code {
368368
.fade-leave-active {
369369
transition: opacity 0.5s;
370370
}
371-
.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
371+
.fade-enter,
372+
.fade-leave-to {
372373
opacity: 0;
373374
}
374375

0 commit comments

Comments
 (0)