-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
Copy pathVPDocAsideOutline.vue
96 lines (79 loc) · 1.85 KB
/
VPDocAsideOutline.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
<script setup lang="ts">
import { ref } from 'vue'
import { useData } from '../composables/data'
import { resolveTitle, useActiveAnchor } from '../composables/outline'
import VPDocOutlineItem from './VPDocOutlineItem.vue'
import { useLayout } from '../composables/layout'
const { theme } = useData()
const container = ref()
const marker = ref()
const { headers, hasLocalNav } = useLayout()
useActiveAnchor(container, marker)
function scrollToTop() {
window.scrollTo({ top: 0, left: 0, behavior: 'smooth' })
}
</script>
<template>
<nav
aria-labelledby="doc-outline-aria-label"
class="VPDocAsideOutline"
:class="{ 'has-outline': hasLocalNav }"
ref="container"
>
<div class="content">
<div class="outline-marker" ref="marker" />
<div
aria-level="2"
class="outline-title"
id="doc-outline-aria-label"
role="heading"
>
{{ resolveTitle(theme) }}
</div>
<VPDocOutlineItem :headers :root="true" />
<button @click="scrollToTop" class="back-to-top-button">
<span>{{ theme.returnToTopLabel || 'Return to top' }}</span>
</button>
</div>
</nav>
</template>
<style scoped>
.VPDocAsideOutline {
display: none;
}
.VPDocAsideOutline.has-outline {
display: block;
}
.content {
position: relative;
border-left: 1px solid var(--vp-c-divider);
padding-left: 16px;
font-size: 13px;
font-weight: 500;
}
.back-to-top-button {
line-height: 32px;
font-weight: 500;
font-size: 14px;
}
.outline-marker {
position: absolute;
top: 32px;
left: -1px;
z-index: 0;
opacity: 0;
width: 2px;
border-radius: 2px;
height: 18px;
background-color: var(--vp-c-brand-1);
transition:
top 0.25s cubic-bezier(0, 1, 0.5, 1),
background-color 0.5s,
opacity 0.25s;
}
.outline-title {
line-height: 32px;
font-size: 14px;
font-weight: 600;
}
</style>