-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathSidebar.vue
129 lines (106 loc) · 2.73 KB
/
Sidebar.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<template>
<div class="sidebar">
<nav class="sidebar__block">
<h2 class="sidebar__heading">Navigation</h2>
<ul class="sidebar__links">
<li class="sidebar__link">
<router-link :to="{name: 'blog.index'}">Home</router-link>
</li>
<li class="sidebar__link">
<router-link :to="{name: 'blog.create'}">Add post</router-link>
</li>
<li class="sidebar__link"><a href="https://webdevetc.com/">Web dev etc blog</a></li>
<li class="sidebar__link">
<a href="https://github.com/WebDevEtc/WebDevEtc-Vue3-Example-Starter">Vue 3 example project on github</a>
</li>
<li class="sidebar__link">
<a href="https://webdevetc.com/blog/vue-3-guide-with-example-code-snippets/">Vue 3 guide</a>
</li>
</ul>
</nav>
<div class="sidebar__block">
<h2 class="sidebar__heading">Top posts</h2>
<ul class="sidebar__links">
<li v-for="post in posts" :key="post.slug" class="sidebar__link">
<router-link :to="{name: 'blog.show', params: {slug: post.slug}}">
{{ post.title }}
<span class="sidebar__upvotes">
({{ post.upvotes }}+)
</span>
</router-link>
</li>
</ul>
</div>
</div>
</template>
<script lang="ts">
import {computed, defineComponent} from 'vue';
import {useStore} from "vuex";
export default defineComponent({
name: 'Sidebar',
components: {},
setup() {
const store = useStore()
return {
posts: computed(() => store.getters.topPosts),
}
},
});
</script>
<style lang="scss">
.sidebar {
&__block {
box-shadow: $box-shadow-standard;
margin: $grid-3;
padding: $grid-1;
@media screen and (min-width: $size-mobile-breakpoint) {
padding: $grid-3;
margin-bottom: $grid-6;
}
}
&__heading {
padding: 0;
margin: $grid-1;
@media screen and (min-width: $size-mobile-breakpoint) {
margin: $grid-3;
}
}
&__links {
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-wrap: wrap;
flex-direction: row;
@media screen and (min-width: $size-mobile-breakpoint) {
flex-direction: column;
}
}
&__link {
padding: 0;
margin: 0 $grid-1;
@media screen and (min-width: $size-mobile-breakpoint) {
margin: 0;
}
&:last-of-type {
padding-bottom: $grid-1;
}
a {
text-align: left;
display: block;
color: $color-text-link;
text-decoration: none;
padding: $grid-5 0 0;
&:hover {
text-decoration: underline;
}
&.router-link-active {
font-weight: $font-weight-bold;
}
}
}
&__upvotes {
color: $colour-secondary;
}
}
</style>