-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSidebar.vue
193 lines (163 loc) · 3.83 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<template>
<aside class="sidebar">
<NavLinks />
<div class="sidebar-content">
<img
v-if="$frontmatter.sidebarImage"
class="img-profile img-profile-sidebar"
:src="$withBase($frontmatter.sidebarImage)"
alt="$frontmatter.sidebarImageAlt"
/>
<slot name="top" />
<SidebarLinks :depth="0" :items="myItems" />
<slot name="bottom" />
</div>
</aside>
</template>
<script>
import SidebarLinks from "@theme/components/SidebarLinks.vue"
import NavLinks from "@theme/components/NavLinks.vue"
export default {
name: "Sidebar",
components: { SidebarLinks, NavLinks },
props: ["items"],
computed: {
myItems() {
// console.info("items", this, "fm:", this.$page)
const sections = this.$frontmatter.sections
if (!sections) {
return this.items
}
const page = this.$page
return [
{
type: "group",
collapsable: false,
title: this.$frontmatter.title || this.$title,
path: page.path + "#app",
children: sections.map((section) => ({
type: "auto",
title: section instanceof Array ? section[1] : section,
basePath: page.path,
path: page.path + "#" + (section instanceof Array ? section[0] : section.toLowerCase()),
children: [],
})),
},
]
},
},
created() {
// console.log("sidebar: ", this.items)
},
}
</script>
<style lang="stylus">
.sidebar-group {
color: $sidebarHeadingTextColor;
}
.sidebar {
display: flex;
flex-direction: column;
background-color: $sidebarBackgroundColor !important; // important needed to fix a CSS processing error in production mode
text-align: center;
ul {
margin: 0;
padding: 0;
list-style-type: none;
}
a {
display: inline-block;
}
.sidebar-content {
margin: auto;
width: 65%;
}
.dropdown-wrapper {
.dropdown-title {
color: $sidebarTextColor;
}
.nav-dropdown {
top: unset;
right: unset;
border-radius: $borderRadius;
background-color: white;
.dropdown-item {
a {
&:hover {
color: $sidebarAccentColor;
}
&.router-link-active {
color: $sidebarAccentColor;
}
}
}
}
}
.img-profile {
max-width: 100%;
max-height: 20vh;
// border: 0.2rem solid $secondary; // fade-out($white, 0.6);
border-radius: $borderRadius;
}
.nav-links {
padding: 0.5rem 0 0.75rem;
// display: none;
border-bottom: 1px solid $borderColor;
a {
font-weight: 600;
}
.nav-item, .repo-link {
display: block;
padding: 0.5rem 1.5rem;
font-size: 1.1em;
line-height: 1.25rem;
}
}
.sidebar-heading {
padding: 0.35rem 0;
color: $sidebarHeadingTextColor;
transition: color $transitionSpeedColor ease;
&.clickable {
&:hover, &.active {
color: $sidebarAccentColor;
}
}
}
.sidebar-links {
// padding: 0.5rem 0;
text-align: left;
& > li > a.sidebar-link {
padding: 0.25em 0 0.25em 1em;
color: $sidebarTextColor;
font-weight: bold;
font-size: 1.1em;
line-height: 1;
transition: color $transitionSpeedColor ease;
&:hover {
color: $sidebarAccentColor;
}
&.active {
border-left-color: $sidebarAccentColor;
color: $sidebarAccentColor;
}
}
}
}
@media (max-width: $MQMobile) {
.sidebar {
transition: transform $transitionSpeedTransform ease;
.nav-links {
display: block;
.dropdown-wrapper .nav-dropdown .dropdown-item a.router-link-active::after {
top: calc(1rem - 2px);
}
}
& > .sidebar-links {
padding: 1rem 0;
}
.img-profile-sidebar {
display: none;
}
}
}
</style>