-
-
Notifications
You must be signed in to change notification settings - Fork 89
/
PressOutline.vue
109 lines (94 loc) · 2.12 KB
/
PressOutline.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
<script setup lang="ts">
import {
useActiveAnchor,
useOutline,
} from 'valaxy'
import { ref } from 'vue'
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
const container = ref()
const marker = ref()
const { headers, handleClick } = useOutline()
useActiveAnchor(container, marker)
</script>
<template>
<div v-show="headers.length" ref="container">
<div class="content">
<div class="outline-title">
{{ t('theme.outlineTitle') }}
</div>
<div ref="marker" class="outline-marker" />
<nav aria-labelledby="doc-outline-aria-label">
<span id="doc-outline-aria-label" class="visually-hidden">
Table of Contents for current page
</span>
<PressOutlineItem
class="va-toc relative z-1 css-i18n-toc"
:headers="headers"
:on-click="handleClick"
root
/>
</nav>
</div>
</div>
</template>
<style lang="scss" scoped>
.va-toc {
text-align: left;
.va-toc-item {
color: var(--va-c-text-light);
}
}
.content {
position: relative;
padding-left: 16px;
font-size: 14px;
text-align: left;
border-left: 1px solid var(--pr-aside-divider);
width: var(--va-aside-width + 16px);
}
.outline-marker {
position: absolute;
top: 32px;
left: -1px;
z-index: 0;
opacity: 0;
width: 1px;
height: 18px;
background-color: var(--va-c-brand);
transition: top 0.25s cubic-bezier(0, 1, 0.5, 1), background-color 0.5s, opacity 0.25s;
border-top-right-radius: 2px;
border-bottom-right-radius: 2px;
}
.outline-title {
letter-spacing: 0.4px;
line-height: 28px;
font-size: 14px;
font-weight: 600;
color: var(--pr-c-text-1);
}
.outline-link {
display: block;
line-height: 28px;
font-size: 13px;
color: var(--pr-aside-text-2);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
transition: color 0.5s;
}
.outline-link:hover,
.outline-link.active {
color: var(--pr-aside-text-1);
transition: color 0.25s;
}
.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
white-space: nowrap;
clip: rect(0 0 0 0);
clip-path: inset(50%);
overflow: hidden;
}
</style>