@vuepress/theme-default 2.0.0-rc.6 → 2.0.0-rc.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client/components/VPDarkIcon.vue +8 -0
- package/lib/client/components/VPDropdownTransition.vue +36 -0
- package/lib/client/components/VPEditIcon.vue +12 -0
- package/lib/client/components/VPHome.vue +38 -0
- package/lib/client/components/VPHomeFeatures.vue +66 -0
- package/lib/client/components/{HomeFooter.vue → VPHomeFooter.vue} +17 -2
- package/lib/client/components/{HomeHero.vue → VPHomeHero.vue} +113 -19
- package/lib/client/components/VPLightIcon.vue +28 -0
- package/lib/client/components/VPNavbar.vue +134 -0
- package/lib/client/components/{NavbarBrand.vue → VPNavbarBrand.vue} +40 -7
- package/lib/client/components/VPNavbarDropdown.vue +334 -0
- package/lib/client/components/VPNavbarItems.vue +111 -0
- package/lib/client/components/VPPage.vue +72 -0
- package/lib/client/components/VPPageMeta.vue +134 -0
- package/lib/client/components/VPPageNav.vue +118 -0
- package/lib/client/components/VPSidebar.vue +113 -0
- package/lib/client/components/VPSidebarItem.vue +174 -0
- package/lib/client/components/{SidebarItems.vue → VPSidebarItems.vue} +32 -7
- package/lib/client/components/VPToggleColorModeButton.vue +55 -0
- package/lib/client/components/VPToggleSidebarButton.vue +92 -0
- package/lib/client/components/global/Badge.vue +84 -18
- package/lib/client/components/global/index.d.ts +1 -3
- package/lib/client/components/global/index.js +1 -3
- package/lib/client/composables/index.d.ts +8 -0
- package/lib/client/composables/index.js +8 -0
- package/lib/client/composables/useContributors.d.ts +3 -0
- package/lib/client/composables/useContributors.js +14 -0
- package/lib/client/composables/useDarkMode.d.ts +0 -1
- package/lib/client/composables/useDarkMode.js +16 -13
- package/lib/client/composables/useEditLink.d.ts +3 -0
- package/lib/client/composables/useEditLink.js +31 -0
- package/lib/client/composables/useLastUpdated.d.ts +2 -0
- package/lib/client/composables/useLastUpdated.js +17 -0
- package/lib/client/composables/useNavbarConfig.d.ts +3 -0
- package/lib/client/composables/useNavbarConfig.js +27 -0
- package/lib/client/composables/useNavbarRepo.d.ts +6 -0
- package/lib/client/composables/useNavbarRepo.js +38 -0
- package/lib/client/composables/useNavbarSelectLanguage.d.ts +6 -0
- package/lib/client/composables/useNavbarSelectLanguage.js +59 -0
- package/lib/client/composables/useNavigate.d.ts +1 -0
- package/lib/client/composables/useNavigate.js +22 -0
- package/lib/client/composables/useRelatedLinks.d.ts +8 -0
- package/lib/client/composables/useRelatedLinks.js +91 -0
- package/lib/client/composables/useScrollPromise.js +3 -1
- package/lib/client/composables/useSidebarItems.d.ts +28 -23
- package/lib/client/composables/useSidebarItems.js +120 -84
- package/lib/client/composables/useUpdateDeviceStatus.d.ts +1 -1
- package/lib/client/composables/useUpdateDeviceStatus.js +10 -5
- package/lib/client/config.d.ts +3 -2
- package/lib/client/config.js +6 -23
- package/lib/client/index.d.ts +2 -1
- package/lib/client/index.js +0 -1
- package/lib/client/layouts/Layout.vue +139 -34
- package/lib/client/layouts/NotFound.vue +17 -5
- package/lib/client/shim.d.ts +12 -3
- package/lib/client/styles/_mixins.scss +4 -4
- package/lib/client/styles/_variables.module.scss +1 -1
- package/lib/client/styles/_variables.scss +2 -1
- package/lib/client/styles/arrow.scss +18 -24
- package/lib/client/styles/code-group.scss +35 -30
- package/lib/client/styles/content/code.scss +23 -0
- package/lib/client/styles/content/index.scss +3 -0
- package/lib/client/styles/content/normalize.scss +39 -0
- package/lib/client/styles/{toc.scss → content/toc.scss} +1 -1
- package/lib/client/styles/external-link-icon.scss +36 -0
- package/lib/client/styles/index.scss +3 -13
- package/lib/client/styles/layout.scss +3 -199
- package/lib/client/styles/normalize.scss +1 -194
- package/lib/client/styles/plugins.scss +28 -0
- package/lib/client/styles/vars-dark.scss +20 -58
- package/lib/client/styles/vars.scss +53 -129
- package/lib/client/typings.d.ts +13 -0
- package/lib/client/typings.js +1 -0
- package/lib/client/utils/getAutoLink.d.ts +9 -0
- package/lib/client/utils/getAutoLink.js +17 -0
- package/lib/client/utils/index.d.ts +3 -2
- package/lib/client/utils/index.js +3 -2
- package/lib/client/utils/isActiveSidebarItem.d.ts +3 -3
- package/lib/client/utils/isActiveSidebarItem.js +3 -3
- package/lib/client/utils/isLinkInternal.d.ts +1 -0
- package/lib/client/utils/isLinkInternal.js +2 -0
- package/lib/client/utils/resolveEditLink.d.ts +1 -1
- package/lib/client/utils/resolvePrefix.d.ts +1 -0
- package/lib/client/utils/resolvePrefix.js +4 -0
- package/lib/client/utils/resolveRepoType.d.ts +1 -1
- package/lib/client/utils/resolveRepoType.js +4 -4
- package/lib/node/defaultTheme.d.ts +2 -1
- package/lib/node/defaultTheme.js +40 -49
- package/lib/node/index.d.ts +2 -3
- package/lib/node/index.js +0 -3
- package/lib/node/typings.d.ts +58 -0
- package/lib/node/typings.js +1 -0
- package/lib/node/utils/assignDefaultLocaleOptions.js +3 -7
- package/lib/node/utils/index.d.ts +1 -1
- package/lib/node/utils/index.js +1 -1
- package/lib/node/utils/resolveMarkdownHintLocales.d.ts +9 -0
- package/lib/node/utils/resolveMarkdownHintLocales.js +19 -0
- package/lib/shared/index.d.ts +5 -3
- package/lib/shared/index.js +1 -3
- package/lib/shared/nav.d.ts +19 -30
- package/lib/shared/navbar.d.ts +21 -0
- package/lib/shared/navbar.js +1 -0
- package/lib/shared/options.d.ts +36 -65
- package/lib/shared/page.d.ts +9 -6
- package/lib/shared/sidebar.d.ts +26 -0
- package/lib/shared/sidebar.js +1 -0
- package/package.json +30 -28
- package/templates/build.html +14 -8
- package/lib/client/components/AutoLink.vue +0 -113
- package/lib/client/components/DropdownTransition.vue +0 -25
- package/lib/client/components/Home.vue +0 -15
- package/lib/client/components/HomeContent.vue +0 -5
- package/lib/client/components/HomeFeatures.vue +0 -22
- package/lib/client/components/Navbar.vue +0 -79
- package/lib/client/components/NavbarDropdown.vue +0 -126
- package/lib/client/components/NavbarItems.vue +0 -199
- package/lib/client/components/Page.vue +0 -31
- package/lib/client/components/PageMeta.vue +0 -124
- package/lib/client/components/PageNav.vue +0 -122
- package/lib/client/components/Sidebar.vue +0 -18
- package/lib/client/components/SidebarItem.vue +0 -87
- package/lib/client/components/ToggleColorModeButton.vue +0 -57
- package/lib/client/components/ToggleSidebarButton.vue +0 -24
- package/lib/client/components/global/CodeGroup.d.ts +0 -6
- package/lib/client/components/global/CodeGroup.js +0 -120
- package/lib/client/components/global/CodeGroupItem.vue +0 -27
- package/lib/client/styles/badge.scss +0 -36
- package/lib/client/styles/code.scss +0 -263
- package/lib/client/styles/custom-container.scss +0 -142
- package/lib/client/styles/home.scss +0 -168
- package/lib/client/styles/navbar-dropdown.scss +0 -183
- package/lib/client/styles/navbar.scss +0 -197
- package/lib/client/styles/page.scss +0 -87
- package/lib/client/styles/sidebar.scss +0 -134
- package/lib/client/styles/transitions.scss +0 -22
- package/lib/client/utils/getNavLink.d.ts +0 -15
- package/lib/client/utils/getNavLink.js +0 -18
- package/lib/client/utils/getResolveRouteWithRedirect.d.ts +0 -5
- package/lib/client/utils/getResolveRouteWithRedirect.js +0 -22
- package/lib/node/utils/resolveContainerPluginOptions.d.ts +0 -8
- package/lib/node/utils/resolveContainerPluginOptions.js +0 -17
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useNavigate } from '@theme/useNavigate'
|
|
3
|
+
import { useRelatedLinks } from '@theme/useRelatedLinks'
|
|
4
|
+
import { useThemeLocaleData } from '@theme/useThemeData'
|
|
5
|
+
import { useEventListener } from '@vueuse/core'
|
|
6
|
+
import { computed } from 'vue'
|
|
7
|
+
import { AutoLink } from 'vuepress/client'
|
|
8
|
+
|
|
9
|
+
const themeLocale = useThemeLocaleData()
|
|
10
|
+
const navigate = useNavigate()
|
|
11
|
+
|
|
12
|
+
const { prevLink, nextLink } = useRelatedLinks()
|
|
13
|
+
|
|
14
|
+
const navbarLabel = computed(
|
|
15
|
+
() => themeLocale.value.pageNavbarLabel ?? 'page navigation',
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
useEventListener('keydown', (event): void => {
|
|
19
|
+
if (event.altKey) {
|
|
20
|
+
if (event.key === 'ArrowRight') {
|
|
21
|
+
if (nextLink.value) {
|
|
22
|
+
navigate(nextLink.value.link)
|
|
23
|
+
event.preventDefault()
|
|
24
|
+
}
|
|
25
|
+
} else if (event.key === 'ArrowLeft') {
|
|
26
|
+
if (prevLink.value) {
|
|
27
|
+
navigate(prevLink.value.link)
|
|
28
|
+
event.preventDefault()
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<!-- eslint-disable-next-line vue/no-root-v-if -->
|
|
36
|
+
<template>
|
|
37
|
+
<nav
|
|
38
|
+
v-if="prevLink || nextLink"
|
|
39
|
+
class="vp-page-nav"
|
|
40
|
+
:aria-label="navbarLabel"
|
|
41
|
+
>
|
|
42
|
+
<AutoLink v-if="prevLink" class="prev" :config="prevLink">
|
|
43
|
+
<div class="hint">
|
|
44
|
+
<span class="arrow left" />
|
|
45
|
+
{{ themeLocale.prev ?? 'Prev' }}
|
|
46
|
+
</div>
|
|
47
|
+
<div class="link">
|
|
48
|
+
<span>{{ prevLink.text }}</span>
|
|
49
|
+
</div>
|
|
50
|
+
</AutoLink>
|
|
51
|
+
|
|
52
|
+
<AutoLink v-if="nextLink" class="next" :config="nextLink">
|
|
53
|
+
<div class="hint">
|
|
54
|
+
{{ themeLocale.next ?? 'Next' }}
|
|
55
|
+
<span class="arrow right" />
|
|
56
|
+
</div>
|
|
57
|
+
<div class="link">
|
|
58
|
+
<span>{{ nextLink.text }}</span>
|
|
59
|
+
</div>
|
|
60
|
+
</AutoLink>
|
|
61
|
+
</nav>
|
|
62
|
+
</template>
|
|
63
|
+
|
|
64
|
+
<style lang="scss">
|
|
65
|
+
@use '../styles/variables' as *;
|
|
66
|
+
|
|
67
|
+
.vp-page-nav {
|
|
68
|
+
display: flex;
|
|
69
|
+
flex-wrap: wrap;
|
|
70
|
+
|
|
71
|
+
max-width: var(--content-width, 740px);
|
|
72
|
+
min-height: 2rem;
|
|
73
|
+
margin-top: 0;
|
|
74
|
+
margin-right: auto;
|
|
75
|
+
margin-left: auto;
|
|
76
|
+
padding: 1rem 2rem 0;
|
|
77
|
+
border-top: 1px solid var(--vp-c-gutter);
|
|
78
|
+
|
|
79
|
+
transition: border-top var(--vp-t-color);
|
|
80
|
+
|
|
81
|
+
@media (max-width: $MQNarrow) {
|
|
82
|
+
padding-right: 1rem;
|
|
83
|
+
padding-left: 1rem;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@media print {
|
|
87
|
+
display: none;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.route-link {
|
|
91
|
+
display: inline-block;
|
|
92
|
+
flex-grow: 1;
|
|
93
|
+
|
|
94
|
+
margin: 0.25rem;
|
|
95
|
+
padding: 0.25rem 0.5rem;
|
|
96
|
+
border: 1px solid var(--vp-c-gutter);
|
|
97
|
+
border-radius: 0.25rem;
|
|
98
|
+
|
|
99
|
+
&:hover {
|
|
100
|
+
background: var(--vp-c-control);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.hint {
|
|
104
|
+
color: var(--vp-c-text-mute);
|
|
105
|
+
font-size: 0.875rem;
|
|
106
|
+
line-height: 2;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.prev {
|
|
111
|
+
text-align: start;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.next {
|
|
115
|
+
text-align: end;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
</style>
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import VPNavbarItems from '@theme/VPNavbarItems.vue'
|
|
3
|
+
import VPSidebarItems from '@theme/VPSidebarItems.vue'
|
|
4
|
+
import type { VNode } from 'vue'
|
|
5
|
+
|
|
6
|
+
defineSlots<{
|
|
7
|
+
top?: (props: Record<never, never>) => VNode | VNode[] | null
|
|
8
|
+
bottom?: (props: Record<never, never>) => VNode | VNode[] | null
|
|
9
|
+
}>()
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<aside class="vp-sidebar" vp-sidebar>
|
|
14
|
+
<VPNavbarItems />
|
|
15
|
+
<slot name="top" />
|
|
16
|
+
<VPSidebarItems />
|
|
17
|
+
<slot name="bottom" />
|
|
18
|
+
</aside>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<style lang="scss">
|
|
22
|
+
@use '../styles/variables' as *;
|
|
23
|
+
|
|
24
|
+
.vp-sidebar {
|
|
25
|
+
position: fixed;
|
|
26
|
+
|
|
27
|
+
// leave space for navbar
|
|
28
|
+
top: var(--navbar-height);
|
|
29
|
+
bottom: 0;
|
|
30
|
+
left: 0;
|
|
31
|
+
z-index: 10;
|
|
32
|
+
|
|
33
|
+
overflow-y: auto;
|
|
34
|
+
|
|
35
|
+
box-sizing: border-box;
|
|
36
|
+
width: var(--sidebar-width);
|
|
37
|
+
margin: 0;
|
|
38
|
+
border-right: 1px solid var(--vp-c-border);
|
|
39
|
+
|
|
40
|
+
background-color: var(--vp-sidebar-c-bg);
|
|
41
|
+
|
|
42
|
+
font-size: 16px;
|
|
43
|
+
|
|
44
|
+
transition:
|
|
45
|
+
transform var(--vp-t-transform),
|
|
46
|
+
background-color var(--vp-t-color),
|
|
47
|
+
border-color var(--vp-t-color);
|
|
48
|
+
|
|
49
|
+
scrollbar-color: var(--vp-c-accent-bg) var(--vp-c-gutter);
|
|
50
|
+
scrollbar-width: thin;
|
|
51
|
+
|
|
52
|
+
// narrow desktop / iPad
|
|
53
|
+
@media (max-width: $MQNarrow) {
|
|
54
|
+
width: var(--sidebar-width-mobile);
|
|
55
|
+
font-size: 15px;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// wide mobile
|
|
59
|
+
@media (max-width: $MQMobile) {
|
|
60
|
+
top: 0;
|
|
61
|
+
|
|
62
|
+
// leave space for navbar
|
|
63
|
+
padding-top: var(--navbar-height);
|
|
64
|
+
transform: translateX(-100%);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&::-webkit-scrollbar {
|
|
68
|
+
width: 7px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&::-webkit-scrollbar-track {
|
|
72
|
+
background-color: var(--vp-c-gutter);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&::-webkit-scrollbar-thumb {
|
|
76
|
+
background-color: var(--vp-c-accent-bg);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// override styles
|
|
80
|
+
.vp-navbar-items {
|
|
81
|
+
display: none;
|
|
82
|
+
padding: 0.5rem 0 0.75rem;
|
|
83
|
+
border-bottom: 1px solid var(--vp-c-gutter);
|
|
84
|
+
transition: border-color var(--vp-t-color);
|
|
85
|
+
|
|
86
|
+
@media (max-width: $MQMobile) {
|
|
87
|
+
display: block;
|
|
88
|
+
|
|
89
|
+
.vp-navbar-dropdown-item a.route-link-active::after {
|
|
90
|
+
top: calc(1rem - 2px);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
ul {
|
|
95
|
+
margin: 0;
|
|
96
|
+
padding: 0;
|
|
97
|
+
list-style-type: none;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
a {
|
|
101
|
+
font-weight: 600;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// override styles
|
|
106
|
+
.vp-navbar-item {
|
|
107
|
+
display: block;
|
|
108
|
+
padding: 0.5rem 0 0.5rem 1.5rem;
|
|
109
|
+
font-size: 1.1em;
|
|
110
|
+
line-height: 1.25rem;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
</style>
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import VPDropdownTransition from '@theme/VPDropdownTransition.vue'
|
|
3
|
+
import { useToggle } from '@vueuse/core'
|
|
4
|
+
import { computed, nextTick, onBeforeUnmount, toRefs } from 'vue'
|
|
5
|
+
import { AutoLink, useRoute, useRouter } from 'vuepress/client'
|
|
6
|
+
import type { SidebarItem } from '../typings.js'
|
|
7
|
+
import { isActiveLinkItem } from '../utils/index.js'
|
|
8
|
+
|
|
9
|
+
const props = withDefaults(
|
|
10
|
+
defineProps<{
|
|
11
|
+
/**
|
|
12
|
+
* The sidebar item to be rendered
|
|
13
|
+
*/
|
|
14
|
+
item: SidebarItem
|
|
15
|
+
/**
|
|
16
|
+
* The depth of the current sidebar item
|
|
17
|
+
*/
|
|
18
|
+
depth?: number
|
|
19
|
+
}>(),
|
|
20
|
+
{ depth: 0 },
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
const { item, depth } = toRefs(props)
|
|
24
|
+
const route = useRoute()
|
|
25
|
+
const router = useRouter()
|
|
26
|
+
|
|
27
|
+
const collapsible = computed(
|
|
28
|
+
() => 'collapsible' in item.value && item.value.collapsible,
|
|
29
|
+
)
|
|
30
|
+
const isActive = computed(() => isActiveLinkItem(item.value, route))
|
|
31
|
+
const itemClass = computed(() => ({
|
|
32
|
+
'vp-sidebar-item': true,
|
|
33
|
+
'vp-sidebar-heading': depth.value === 0,
|
|
34
|
+
'active': isActive.value,
|
|
35
|
+
'collapsible': collapsible.value,
|
|
36
|
+
}))
|
|
37
|
+
|
|
38
|
+
const isOpenDefault = computed(() =>
|
|
39
|
+
collapsible.value ? isActive.value : true,
|
|
40
|
+
)
|
|
41
|
+
// eslint-disable-next-line vue/no-ref-object-reactivity-loss
|
|
42
|
+
const [isOpen, toggleIsOpen] = useToggle(isOpenDefault.value)
|
|
43
|
+
const onClick = (e: Event): void => {
|
|
44
|
+
if (collapsible.value) {
|
|
45
|
+
e.preventDefault()
|
|
46
|
+
// toggle open status on click
|
|
47
|
+
toggleIsOpen()
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// reset open status after navigation
|
|
52
|
+
const unregisterRouterHook = router.afterEach(() => {
|
|
53
|
+
void nextTick(() => {
|
|
54
|
+
isOpen.value = isOpenDefault.value
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
onBeforeUnmount(() => {
|
|
58
|
+
unregisterRouterHook()
|
|
59
|
+
})
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<template>
|
|
63
|
+
<li>
|
|
64
|
+
<AutoLink v-if="item.link" :class="itemClass" :config="item" />
|
|
65
|
+
<p
|
|
66
|
+
v-else
|
|
67
|
+
tabindex="0"
|
|
68
|
+
:class="itemClass"
|
|
69
|
+
@click="onClick"
|
|
70
|
+
@keydown.enter="onClick"
|
|
71
|
+
>
|
|
72
|
+
{{ item.text }}
|
|
73
|
+
<span
|
|
74
|
+
v-if="collapsible"
|
|
75
|
+
class="arrow"
|
|
76
|
+
:class="isOpen ? 'down' : 'right'"
|
|
77
|
+
/>
|
|
78
|
+
</p>
|
|
79
|
+
|
|
80
|
+
<VPDropdownTransition v-if="'children' in item && item.children.length">
|
|
81
|
+
<ul v-show="isOpen" class="vp-sidebar-children">
|
|
82
|
+
<VPSidebarItem
|
|
83
|
+
v-for="child in item.children"
|
|
84
|
+
:key="`${depth}${child.text}${child.link}`"
|
|
85
|
+
:item="child"
|
|
86
|
+
:depth="depth + 1"
|
|
87
|
+
/>
|
|
88
|
+
</ul>
|
|
89
|
+
</VPDropdownTransition>
|
|
90
|
+
</li>
|
|
91
|
+
</template>
|
|
92
|
+
|
|
93
|
+
<style lang="scss">
|
|
94
|
+
@use '../styles/mixins';
|
|
95
|
+
@use '../styles/variables' as *;
|
|
96
|
+
|
|
97
|
+
.vp-sidebar-item {
|
|
98
|
+
border-left: 0.25rem solid transparent;
|
|
99
|
+
color: var(--vp-c-text);
|
|
100
|
+
cursor: default;
|
|
101
|
+
|
|
102
|
+
&:focus-visible {
|
|
103
|
+
outline-width: 1px;
|
|
104
|
+
outline-offset: -1px;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
&.vp-sidebar-heading {
|
|
108
|
+
box-sizing: border-box;
|
|
109
|
+
width: 100%;
|
|
110
|
+
margin: 0;
|
|
111
|
+
padding: 0.35rem 1.5rem 0.35rem 1.25rem;
|
|
112
|
+
|
|
113
|
+
font-weight: bold;
|
|
114
|
+
font-size: 1.1em;
|
|
115
|
+
|
|
116
|
+
transition: color 0.15s ease;
|
|
117
|
+
|
|
118
|
+
+ .vp-sidebar-children {
|
|
119
|
+
@include mixins.dropdown-wrapper;
|
|
120
|
+
|
|
121
|
+
margin-bottom: 0.75rem;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
&.collapsible {
|
|
126
|
+
cursor: pointer;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
&:not(.vp-sidebar-heading) {
|
|
130
|
+
display: inline-block;
|
|
131
|
+
|
|
132
|
+
box-sizing: border-box;
|
|
133
|
+
width: 100%;
|
|
134
|
+
margin: 0;
|
|
135
|
+
padding: 0.35rem 1rem 0.35rem 2rem;
|
|
136
|
+
|
|
137
|
+
font-weight: 400;
|
|
138
|
+
font-size: 1em;
|
|
139
|
+
line-height: 1.4;
|
|
140
|
+
|
|
141
|
+
+ .vp-sidebar-children {
|
|
142
|
+
padding-left: 1rem;
|
|
143
|
+
font-size: 0.95em;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.vp-sidebar-children .vp-sidebar-children & {
|
|
147
|
+
padding: 0.25rem 1rem 0.25rem 1.75rem;
|
|
148
|
+
|
|
149
|
+
&.active {
|
|
150
|
+
border-left-color: transparent;
|
|
151
|
+
font-weight: 500;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
a.vp-sidebar-heading + .vp-sidebar-children &.active {
|
|
156
|
+
border-left-color: transparent;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
&.active:not(p.vp-sidebar-heading) {
|
|
161
|
+
border-left-color: var(--vp-c-accent);
|
|
162
|
+
color: var(--vp-c-accent);
|
|
163
|
+
font-weight: 600;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
a.vp-sidebar-item {
|
|
168
|
+
cursor: pointer;
|
|
169
|
+
|
|
170
|
+
&:hover {
|
|
171
|
+
color: var(--vp-c-accent);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
</style>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import
|
|
2
|
+
import VPSidebarItem from '@theme/VPSidebarItem.vue'
|
|
3
|
+
import { useSidebarItems } from '@theme/useSidebarItems'
|
|
3
4
|
import { onMounted, watch } from 'vue'
|
|
4
|
-
import { useRoute } from '
|
|
5
|
-
import { useSidebarItems } from '../composables/index.js'
|
|
5
|
+
import { useRoute } from 'vuepress/client'
|
|
6
6
|
|
|
7
7
|
const route = useRoute()
|
|
8
8
|
const sidebarItems = useSidebarItems()
|
|
@@ -12,12 +12,12 @@ onMounted(() => {
|
|
|
12
12
|
() => route.hash,
|
|
13
13
|
(hash) => {
|
|
14
14
|
// get the sidebar DOM
|
|
15
|
-
const sidebar = document.querySelector('.sidebar')
|
|
15
|
+
const sidebar = document.querySelector('.vp-sidebar')
|
|
16
16
|
if (!sidebar) return
|
|
17
17
|
|
|
18
18
|
// get the active sidebar item DOM, whose href equals to the current route
|
|
19
19
|
const activeSidebarItem = document.querySelector(
|
|
20
|
-
`.sidebar a.sidebar-item[href="${route.path}${hash}"]`,
|
|
20
|
+
`.vp-sidebar a.vp-sidebar-item[href="${route.path}${hash}"]`,
|
|
21
21
|
)
|
|
22
22
|
if (!activeSidebarItem) return
|
|
23
23
|
|
|
@@ -46,12 +46,37 @@ onMounted(() => {
|
|
|
46
46
|
})
|
|
47
47
|
</script>
|
|
48
48
|
|
|
49
|
+
<!-- eslint-disable-next-line vue/no-root-v-if -->
|
|
49
50
|
<template>
|
|
50
|
-
<ul v-if="sidebarItems.length" class="sidebar-items">
|
|
51
|
-
<
|
|
51
|
+
<ul v-if="sidebarItems.length" class="vp-sidebar-items">
|
|
52
|
+
<VPSidebarItem
|
|
52
53
|
v-for="item in sidebarItems"
|
|
53
54
|
:key="`${item.text}${item.link}`"
|
|
54
55
|
:item="item"
|
|
55
56
|
/>
|
|
56
57
|
</ul>
|
|
57
58
|
</template>
|
|
59
|
+
|
|
60
|
+
<style lang="scss">
|
|
61
|
+
@use '../styles/variables' as *;
|
|
62
|
+
|
|
63
|
+
.vp-sidebar-items {
|
|
64
|
+
margin: 0;
|
|
65
|
+
padding: 1.5rem 0;
|
|
66
|
+
list-style-type: none;
|
|
67
|
+
|
|
68
|
+
@media (max-width: $MQMobile) {
|
|
69
|
+
padding: 1rem 0;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
ul {
|
|
73
|
+
margin: 0;
|
|
74
|
+
padding: 0;
|
|
75
|
+
list-style-type: none;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
a {
|
|
79
|
+
display: inline-block;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
</style>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import VPDarkIcon from '@theme/VPDarkIcon.vue'
|
|
3
|
+
import VPLightIcon from '@theme/VPLightIcon.vue'
|
|
4
|
+
import { useDarkMode } from '@theme/useDarkMode'
|
|
5
|
+
import { useThemeLocaleData } from '@theme/useThemeData'
|
|
6
|
+
|
|
7
|
+
const themeLocale = useThemeLocaleData()
|
|
8
|
+
const isDarkMode = useDarkMode()
|
|
9
|
+
|
|
10
|
+
const toggleColorMode = (): void => {
|
|
11
|
+
isDarkMode.value = !isDarkMode.value
|
|
12
|
+
}
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<template>
|
|
16
|
+
<button
|
|
17
|
+
type="button"
|
|
18
|
+
class="vp-toggle-color-mode-button"
|
|
19
|
+
:title="themeLocale.toggleColorMode"
|
|
20
|
+
@click="toggleColorMode"
|
|
21
|
+
>
|
|
22
|
+
<VPLightIcon v-show="!isDarkMode" />
|
|
23
|
+
<VPDarkIcon v-show="isDarkMode" />
|
|
24
|
+
</button>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<style lang="scss">
|
|
28
|
+
.vp-toggle-color-mode-button {
|
|
29
|
+
display: flex;
|
|
30
|
+
|
|
31
|
+
margin: auto;
|
|
32
|
+
margin-left: 1rem;
|
|
33
|
+
border: 0;
|
|
34
|
+
|
|
35
|
+
background: none;
|
|
36
|
+
color: var(--vp-c-text);
|
|
37
|
+
|
|
38
|
+
opacity: 0.8;
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
|
|
41
|
+
@media print {
|
|
42
|
+
display: none;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&:hover {
|
|
46
|
+
opacity: 1;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.light-icon,
|
|
50
|
+
.dark-icon {
|
|
51
|
+
width: 1.25rem;
|
|
52
|
+
height: 1.25rem;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
</style>
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useThemeLocaleData } from '@theme/useThemeData'
|
|
3
|
+
|
|
4
|
+
defineEmits<{ toggle: [] }>()
|
|
5
|
+
|
|
6
|
+
const themeLocale = useThemeLocaleData()
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<div
|
|
11
|
+
class="vp-toggle-sidebar-button"
|
|
12
|
+
:title="themeLocale.toggleSidebar"
|
|
13
|
+
aria-expanded="false"
|
|
14
|
+
role="button"
|
|
15
|
+
tabindex="0"
|
|
16
|
+
@click="$emit('toggle')"
|
|
17
|
+
>
|
|
18
|
+
<div class="icon" aria-hidden="true">
|
|
19
|
+
<span></span>
|
|
20
|
+
<span></span>
|
|
21
|
+
<span></span>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<style lang="scss">
|
|
27
|
+
/* stylelint-disable max-nesting-depth */
|
|
28
|
+
@use '../styles/variables' as *;
|
|
29
|
+
|
|
30
|
+
.vp-toggle-sidebar-button {
|
|
31
|
+
position: absolute;
|
|
32
|
+
top: 0.6rem;
|
|
33
|
+
left: 1rem;
|
|
34
|
+
|
|
35
|
+
display: none;
|
|
36
|
+
|
|
37
|
+
padding: 0.6rem;
|
|
38
|
+
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
|
|
41
|
+
@media screen and (max-width: $MQMobile) {
|
|
42
|
+
display: block;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.icon {
|
|
46
|
+
display: flex;
|
|
47
|
+
flex-direction: column;
|
|
48
|
+
align-items: center;
|
|
49
|
+
justify-content: center;
|
|
50
|
+
|
|
51
|
+
width: 1.25rem;
|
|
52
|
+
height: 1.25rem;
|
|
53
|
+
|
|
54
|
+
cursor: inherit;
|
|
55
|
+
|
|
56
|
+
span {
|
|
57
|
+
display: inline-block;
|
|
58
|
+
|
|
59
|
+
width: 100%;
|
|
60
|
+
height: 2px;
|
|
61
|
+
border-radius: 2px;
|
|
62
|
+
|
|
63
|
+
background-color: var(--vp-c-text);
|
|
64
|
+
|
|
65
|
+
transition: transform var(--vp-t-transform);
|
|
66
|
+
|
|
67
|
+
&:nth-child(2) {
|
|
68
|
+
margin: 6px 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.vp-theme-container.sidebar-open & {
|
|
72
|
+
&:nth-child(1) {
|
|
73
|
+
transform: rotate(45deg) translate3d(5.5px, 5.5px, 0);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
&:nth-child(2) {
|
|
77
|
+
transform: scale3d(0, 1, 1);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&:nth-child(3) {
|
|
81
|
+
transform: rotate(-45deg) translate3d(6px, -6px, 0);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&:nth-child(1),
|
|
85
|
+
&:nth-child(3) {
|
|
86
|
+
transform-origin: center;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
</style>
|