Skip to content

Commit 0ff2222

Browse files
committed
notifications dropdown
1 parent da4cff1 commit 0ff2222

File tree

2 files changed

+63
-7
lines changed

2 files changed

+63
-7
lines changed

frontend/src/components/shared/NavBar.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!-- eslint-disable max-len -->
33
<!-- eslint-disable vue/no-deprecated-v-on-native-modifier -->
44
<nav class="md:flex md:justify-between md:items-center md:py-5">
5-
<div class="flex items-center justify-between px-5 py-3 md:p-0">
5+
<div class="flex items-center justify-between px-5 py-3 md:p-0 w-full">
66
<div id="logo">
77
<router-link to="/">
88
<div class="flex justify-center items-center">
@@ -11,7 +11,7 @@
1111
</div>
1212
</router-link>
1313
</div>
14-
<NavBarBell v-if="loggedIn" class="md:invisible"></NavBarBell>
14+
<NavBarBell v-if="loggedIn"></NavBarBell>
1515
<div id="burger" class="md:hidden">
1616
<button type="button" class="block text-gray-800 focus:outline-none" v-on:click="isOpen = !isOpen">
1717
<svg class="w-8 h-8 text-purple-matcha fill-current" viewBox="0 0 24 24">
@@ -21,7 +21,6 @@
2121
</button>
2222
</div>
2323
</div>
24-
<NavBarBell v-if="loggedIn" class="invisible md:visible"></NavBarBell>
2524
<div id="links" v-on:click="isOpen = !isOpen" v-bind:class="isOpen ? 'block' : 'hidden'" class="px-2 pb-5 text-center md:p-0 md:block md:flex md:items-center">
2625
<div v-if="!loggedIn" class="md:flex md:bg-purple-matcha md:border-2 md:border-purple-matcha md:rounded-lg">
2726
<router-link to="/accounts/signin" class="navigation-button-logged-in md:hover:bg-white-matcha md:hover:text-purple-matcha md:text-purple-matcha md:bg-white-matcha md:py-2 md:px-8 md:rounded-md mx-0">Sign In</router-link>
Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,72 @@
11
<template>
22
<!-- eslint-disable max-len -->
3-
<div class="ml-auto mr-8 cursor-pointer relative pr-1">
4-
<img src="../../assets/bell.png" class="w-5">
5-
<div v-if="notify" class="w-3 h-3 bg-purple-matcha rounded-full absolute right-0 bottom-0 ml-2 pl-1"></div>
3+
<div class="ml-auto mr-8 relative pr-1 z-50 outline-none" @focusout="close" tabindex="1">
4+
<div class="outline-none">
5+
<img v-on:click="toggle()" src="../../assets/bell.png" class="w-5 cursor-pointer">
6+
<div v-on:click="toggle()" v-if="notify" class="w-3 h-3 bg-purple-matcha cursor-pointer rounded-full absolute right-0 bottom-0 ml-2 pl-1"></div>
7+
</div>
8+
<div
9+
id="notifications"
10+
v-bind:class="{
11+
'hidden': !showNotifications,
12+
'p-4': true,
13+
'overflow-scroll': notifications.length > 3,
14+
'bg-white': true,
15+
'shadow': true,
16+
'w-64': true,
17+
'h-auto': notifications.length <= 3,
18+
'h-48': notifications.length > 3,
19+
'absolute': true,
20+
'top-0': true,
21+
'mt-10': true,
22+
'z-50': true,
23+
'rounded-md': true}">
24+
<div v-for="notification in notifications" :key="notification.id">{{notification.text}}</div>
25+
</div>
626
</div>
727
</template>
828

929
<script>
1030
export default {
1131
data: () => ({
12-
notify: false,
32+
notify: true,
33+
notifications: [
34+
{ text: 'Samantha liked you', id: 1 },
35+
{ text: 'Bae liked you', id: 2 },
36+
{ text: 'Samantha liked you', id: 3 },
37+
{ text: 'Bae liked you', id: 4 },
38+
{ text: 'Samantha liked you', id: 5 },
39+
{ text: 'Bae liked you', id: 6 },
40+
{ text: 'Samantha liked you', id: 7 },
41+
{ text: 'Bae liked you', id: 8 },
42+
{ text: 'Samantha liked you', id: 9 },
43+
{ text: 'Bae liked you', id: 10 },
44+
],
45+
showNotifications: false,
1346
}),
47+
methods: {
48+
toggle() {
49+
this.showNotifications = !this.showNotifications;
50+
},
51+
close(event) {
52+
if (!event.currentTarget.contains(event.relatedTarget)) {
53+
this.showNotifications = false;
54+
this.notify = false;
55+
}
56+
},
57+
},
1458
};
1559
</script>
60+
61+
<style>
62+
63+
#notifications {
64+
@apply -ml-64;
65+
}
66+
67+
@screen md {
68+
#notifications {
69+
@apply ml-0;
70+
}
71+
}
72+
</style>

0 commit comments

Comments
 (0)