-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathNavBar.vue
108 lines (101 loc) · 2.88 KB
/
NavBar.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<template>
<div>
<b-navbar toggleable="md" type="light" variant="light" fixed="top">
<b-navbar-brand :to="{ path: '/' }">
<img src="~/static/icon.png" width="25" />
Company name
</b-navbar-brand>
<b-navbar-toggle target="nav-collapse"></b-navbar-toggle>
<b-collapse id="nav-collapse" is-nav>
<b-navbar-nav>
<b-nav-item :to="{ path: '/' }" data-cy="nav-bar-home">
Home
</b-nav-item>
<b-nav-item :to="{ path: '/todo' }" data-cy="nav-bar-todo">
Todo
</b-nav-item>
<b-nav-item
:to="{ path: '/another-page' }"
data-cy="nav-bar-another-page"
>
Another Page
</b-nav-item>
<b-nav-item-dropdown
data-cy="nav-bar-sample-page"
text="Sample Page"
right
>
<b-dropdown-item
:to="{ path: '/sample-page/1' }"
data-cy="nav-bar-sample-page-1"
>
Page 1
</b-dropdown-item>
<b-dropdown-item
:to="{ path: '/sample-page/2' }"
data-cy="nav-bar-sample-page-2"
>
Page 2
</b-dropdown-item>
</b-nav-item-dropdown>
</b-navbar-nav>
<!-- Right aligned nav items -->
<b-navbar-nav v-if="isLoggedIn() === true" class="ml-auto">
<b-nav-item
v-if="user"
:to="{ path: '/account' }"
data-cy="nav-bar-welcome-text"
link-classes="btn btn-link mx-1"
>
Welcome, {{ user.first_name }}
</b-nav-item>
<b-nav-item
:to="{ path: '/account' }"
data-cy="nav-bar-account"
link-classes="btn btn-info text-light mx-1"
>
My Account
</b-nav-item>
<b-nav-item
:to="{ path: '/logout' }"
data-cy="nav-bar-logout"
link-classes="btn btn-grey mx-1 text-dark"
>
Logout
</b-nav-item>
</b-navbar-nav>
<b-navbar-nav v-else class="ml-auto">
<b-nav-item
:to="{ path: '/login' }"
data-cy="nav-bar-login"
link-classes="btn btn-info text-light mx-1"
>
Login
</b-nav-item>
<b-nav-item
:to="{ path: '/register' }"
data-cy="nav-bar-register"
link-classes="btn btn-primary mx-1 text-light"
>
Sign up
</b-nav-item>
</b-navbar-nav>
</b-collapse>
</b-navbar>
</div>
</template>
<script>
import { mapGetters, mapState } from 'vuex'
export default {
name: 'NavBar',
computed: {
...mapState('auth', ['user']),
...mapGetters('auth', ['isLoggedIn'])
}
}
</script>
<style scoped>
.client-only-placeholder {
margin-left: auto;
}
</style>