@vuepress/theme-default 2.0.0-beta.45 → 2.0.0-beta.48
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/AutoLink.vue +3 -2
- package/lib/client/components/HomeContent.vue +1 -1
- package/lib/client/components/Navbar.vue +2 -3
- package/lib/client/components/Page.vue +4 -0
- package/lib/client/components/PageMeta.vue +1 -5
- package/lib/client/components/SidebarItems.vue +34 -31
- package/lib/client/components/{ToggleDarkModeButton.vue → ToggleColorModeButton.vue} +4 -4
- package/lib/client/components/global/CodeGroup.d.ts +1 -2
- package/lib/client/components/global/CodeGroup.js +1 -1
- package/lib/client/components/global/index.d.ts +4 -0
- package/lib/client/components/global/index.js +4 -0
- package/lib/client/composables/useDarkMode.js +4 -4
- package/lib/client/config.js +1 -3
- package/lib/client/layouts/Layout.vue +7 -1
- package/lib/client/styles/home.scss +5 -0
- package/lib/client/styles/layout.scss +25 -38
- package/lib/client/styles/navbar.scss +2 -2
- package/lib/client/styles/normalize.scss +1 -1
- package/lib/client/styles/page.scss +5 -0
- package/lib/node/utils/assignDefaultLocaleOptions.js +4 -2
- package/lib/shared/options.d.ts +14 -8
- package/package.json +19 -19
|
@@ -5,14 +5,15 @@ import { defineComponent } from 'vue'
|
|
|
5
5
|
export default defineComponent({
|
|
6
6
|
inheritAttrs: false,
|
|
7
7
|
})
|
|
8
|
+
/* eslint-enable import/order */
|
|
8
9
|
</script>
|
|
9
10
|
|
|
10
11
|
<script setup lang="ts">
|
|
12
|
+
import { useSiteData } from '@vuepress/client'
|
|
13
|
+
import { isLinkHttp, isLinkMailto, isLinkTel } from '@vuepress/shared'
|
|
11
14
|
import { computed, toRefs } from 'vue'
|
|
12
15
|
import type { PropType } from 'vue'
|
|
13
16
|
import { useRoute } from 'vue-router'
|
|
14
|
-
import { useSiteData } from '@vuepress/client'
|
|
15
|
-
import { isLinkHttp, isLinkMailto, isLinkTel } from '@vuepress/shared'
|
|
16
17
|
import type { NavLink } from '../../shared'
|
|
17
18
|
|
|
18
19
|
const props = defineProps({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import NavbarBrand from '@theme/NavbarBrand.vue'
|
|
3
3
|
import NavbarItems from '@theme/NavbarItems.vue'
|
|
4
|
-
import
|
|
4
|
+
import ToggleColorModeButton from '@theme/ToggleColorModeButton.vue'
|
|
5
5
|
import ToggleSidebarButton from '@theme/ToggleSidebarButton.vue'
|
|
6
6
|
import { computed, onMounted, ref } from 'vue'
|
|
7
7
|
import { useThemeLocaleData } from '../composables'
|
|
@@ -22,7 +22,6 @@ const linksWrapperStyle = computed(() => {
|
|
|
22
22
|
maxWidth: linksWrapperMaxWidth.value + 'px',
|
|
23
23
|
}
|
|
24
24
|
})
|
|
25
|
-
const enableDarkMode = computed(() => themeLocale.value.darkMode)
|
|
26
25
|
|
|
27
26
|
// avoid overlapping of long title and long navbar links
|
|
28
27
|
onMounted(() => {
|
|
@@ -69,7 +68,7 @@ function getCssValue(el: HTMLElement | null, property: string): number {
|
|
|
69
68
|
<slot name="before" />
|
|
70
69
|
<NavbarItems class="can-hide" />
|
|
71
70
|
<slot name="after" />
|
|
72
|
-
<
|
|
71
|
+
<ToggleColorModeButton v-if="themeLocale.colorModeSwitch" />
|
|
73
72
|
<NavbarSearch />
|
|
74
73
|
</div>
|
|
75
74
|
</header>
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import AutoLink from '@theme/AutoLink.vue'
|
|
3
|
-
import {
|
|
4
|
-
usePageData,
|
|
5
|
-
usePageFrontmatter,
|
|
6
|
-
useSiteLocaleData,
|
|
7
|
-
} from '@vuepress/client'
|
|
3
|
+
import { usePageData, usePageFrontmatter } from '@vuepress/client'
|
|
8
4
|
import { computed } from 'vue'
|
|
9
5
|
import type { ComputedRef } from 'vue'
|
|
10
6
|
import type {
|
|
@@ -1,46 +1,49 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import SidebarItem from '@theme/SidebarItem.vue'
|
|
3
|
-
import { watch } from 'vue'
|
|
3
|
+
import { onMounted, watch } from 'vue'
|
|
4
4
|
import { useRoute } from 'vue-router'
|
|
5
5
|
import { useSidebarItems } from '../composables'
|
|
6
6
|
|
|
7
7
|
const route = useRoute()
|
|
8
8
|
const sidebarItems = useSidebarItems()
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
onMounted(() => {
|
|
11
|
+
watch(
|
|
12
|
+
() => route.hash,
|
|
13
|
+
(hash) => {
|
|
14
|
+
// get the sidebar DOM
|
|
15
|
+
const sidebar = document.querySelector('.sidebar')
|
|
16
|
+
if (!sidebar) return
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
// get the active sidebar item DOM, whose href equals to the current route
|
|
19
|
+
const activeSidebarItem = document.querySelector(
|
|
20
|
+
`.sidebar a.sidebar-item[href="${route.path}${hash}"]`
|
|
21
|
+
)
|
|
22
|
+
if (!activeSidebarItem) return
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
// get the top and height of the sidebar
|
|
25
|
+
const { top: sidebarTop, height: sidebarHeight } =
|
|
26
|
+
sidebar.getBoundingClientRect()
|
|
27
|
+
// get the top and height of the active sidebar item
|
|
28
|
+
const { top: activeSidebarItemTop, height: activeSidebarItemHeight } =
|
|
29
|
+
activeSidebarItem.getBoundingClientRect()
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
activeSidebarItem.scrollIntoView(false)
|
|
31
|
+
// when the active sidebar item overflows the top edge of sidebar
|
|
32
|
+
if (activeSidebarItemTop < sidebarTop) {
|
|
33
|
+
// scroll to the top edge of sidebar
|
|
34
|
+
activeSidebarItem.scrollIntoView(true)
|
|
35
|
+
}
|
|
36
|
+
// when the active sidebar item overflows the bottom edge of sidebar
|
|
37
|
+
else if (
|
|
38
|
+
activeSidebarItemTop + activeSidebarItemHeight >
|
|
39
|
+
sidebarTop + sidebarHeight
|
|
40
|
+
) {
|
|
41
|
+
// scroll to the bottom edge of sidebar
|
|
42
|
+
activeSidebarItem.scrollIntoView(false)
|
|
43
|
+
}
|
|
41
44
|
}
|
|
42
|
-
|
|
43
|
-
)
|
|
45
|
+
)
|
|
46
|
+
})
|
|
44
47
|
</script>
|
|
45
48
|
|
|
46
49
|
<template>
|
|
@@ -4,16 +4,16 @@ import { useDarkMode, useThemeLocaleData } from '../composables'
|
|
|
4
4
|
const themeLocale = useThemeLocaleData()
|
|
5
5
|
const isDarkMode = useDarkMode()
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const toggleColorMode = (): void => {
|
|
8
8
|
isDarkMode.value = !isDarkMode.value
|
|
9
9
|
}
|
|
10
10
|
</script>
|
|
11
11
|
|
|
12
12
|
<template>
|
|
13
13
|
<button
|
|
14
|
-
class="toggle-
|
|
15
|
-
:title="themeLocale.
|
|
16
|
-
@click="
|
|
14
|
+
class="toggle-color-mode-button"
|
|
15
|
+
:title="themeLocale.toggleColorMode"
|
|
16
|
+
@click="toggleColorMode"
|
|
17
17
|
>
|
|
18
18
|
<svg
|
|
19
19
|
v-show="!isDarkMode"
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { VNode } from 'vue';
|
|
2
|
-
declare const
|
|
2
|
+
export declare const CodeGroup: import("vue").DefineComponent<{}, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
3
3
|
[key: string]: any;
|
|
4
4
|
}> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
|
|
5
|
-
export default _default;
|
|
@@ -18,12 +18,12 @@ export const useDarkMode = () => {
|
|
|
18
18
|
export const setupDarkMode = () => {
|
|
19
19
|
const themeLocale = useThemeLocaleData();
|
|
20
20
|
const isDarkPreferred = usePreferredDark();
|
|
21
|
-
const darkStorage = useStorage('vuepress-color-scheme',
|
|
21
|
+
const darkStorage = useStorage('vuepress-color-scheme', themeLocale.value.colorMode);
|
|
22
22
|
const isDarkMode = computed({
|
|
23
23
|
get() {
|
|
24
|
-
// disable
|
|
25
|
-
if (!themeLocale.value.
|
|
26
|
-
return
|
|
24
|
+
// disable color mode switching
|
|
25
|
+
if (!themeLocale.value.colorModeSwitch) {
|
|
26
|
+
return themeLocale.value.colorMode === 'dark';
|
|
27
27
|
}
|
|
28
28
|
// auto detected from prefers-color-scheme
|
|
29
29
|
if (darkStorage.value === 'auto') {
|
package/lib/client/config.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { defineClientConfig } from '@vuepress/client';
|
|
2
2
|
import { h } from 'vue';
|
|
3
|
-
import Badge from './components/global
|
|
4
|
-
import CodeGroup from './components/global/CodeGroup';
|
|
5
|
-
import CodeGroupItem from './components/global/CodeGroupItem.vue';
|
|
3
|
+
import { Badge, CodeGroup, CodeGroupItem } from './components/global';
|
|
6
4
|
import { setupDarkMode, setupSidebarItems, useScrollPromise, } from './composables';
|
|
7
5
|
import './styles/index.scss';
|
|
8
6
|
export default defineClientConfig({
|
|
@@ -4,7 +4,7 @@ import Navbar from '@theme/Navbar.vue'
|
|
|
4
4
|
import Page from '@theme/Page.vue'
|
|
5
5
|
import Sidebar from '@theme/Sidebar.vue'
|
|
6
6
|
import { usePageData, usePageFrontmatter } from '@vuepress/client'
|
|
7
|
-
import { computed, onMounted, onUnmounted, ref
|
|
7
|
+
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
|
8
8
|
import { useRouter } from 'vue-router'
|
|
9
9
|
import type { DefaultThemePageFrontmatter } from '../../shared'
|
|
10
10
|
import {
|
|
@@ -118,6 +118,12 @@ const onBeforeLeave = scrollPromise.pending
|
|
|
118
118
|
<template #top>
|
|
119
119
|
<slot name="page-top" />
|
|
120
120
|
</template>
|
|
121
|
+
<template #content-top>
|
|
122
|
+
<slot name="page-content-top" />
|
|
123
|
+
</template>
|
|
124
|
+
<template #content-bottom>
|
|
125
|
+
<slot name="page-content-bottom" />
|
|
126
|
+
</template>
|
|
121
127
|
<template #bottom>
|
|
122
128
|
<slot name="page-bottom" />
|
|
123
129
|
</template>
|
|
@@ -86,14 +86,16 @@
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
&.no-navbar {
|
|
89
|
-
.theme-default-content
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
89
|
+
.theme-default-content {
|
|
90
|
+
h1,
|
|
91
|
+
h2,
|
|
92
|
+
h3,
|
|
93
|
+
h4,
|
|
94
|
+
h5,
|
|
95
|
+
h6 {
|
|
96
|
+
margin-top: 1.5rem;
|
|
97
|
+
padding-top: 0;
|
|
98
|
+
}
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
.page {
|
|
@@ -118,13 +120,21 @@
|
|
|
118
120
|
}
|
|
119
121
|
}
|
|
120
122
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
123
|
+
.theme-default-content {
|
|
124
|
+
a:hover {
|
|
125
|
+
text-decoration: underline;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
img {
|
|
129
|
+
max-width: 100%;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
h1,
|
|
133
|
+
h2,
|
|
134
|
+
h3,
|
|
135
|
+
h4,
|
|
136
|
+
h5,
|
|
137
|
+
h6 {
|
|
128
138
|
margin-top: calc(0.5rem - var(--navbar-height));
|
|
129
139
|
padding-top: calc(1rem + var(--navbar-height));
|
|
130
140
|
margin-bottom: 0;
|
|
@@ -141,29 +151,6 @@ h6 {
|
|
|
141
151
|
}
|
|
142
152
|
}
|
|
143
153
|
|
|
144
|
-
.theme-default-content:not(.custom) {
|
|
145
|
-
@include content_wrapper;
|
|
146
|
-
|
|
147
|
-
padding-top: 0;
|
|
148
|
-
|
|
149
|
-
a:hover {
|
|
150
|
-
text-decoration: underline;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
img {
|
|
154
|
-
max-width: 100%;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
.theme-default-content.custom {
|
|
159
|
-
padding: 0;
|
|
160
|
-
margin: 0;
|
|
161
|
-
|
|
162
|
-
img {
|
|
163
|
-
max-width: 100%;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
154
|
// narrow desktop / iPad
|
|
168
155
|
@media (max-width: $MQNarrow) {
|
|
169
156
|
.sidebar {
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.assignDefaultLocaleOptions = exports.DEFAULT_LOCALE_DATA = exports.DEFAULT_LOCALE_OPTIONS = void 0;
|
|
4
4
|
exports.DEFAULT_LOCALE_OPTIONS = {
|
|
5
|
+
// color mode
|
|
6
|
+
colorMode: 'auto',
|
|
7
|
+
colorModeSwitch: true,
|
|
5
8
|
// navbar
|
|
6
9
|
navbar: [],
|
|
7
10
|
logo: null,
|
|
8
|
-
darkMode: true,
|
|
9
11
|
repo: null,
|
|
10
12
|
selectLanguageText: 'Languages',
|
|
11
13
|
selectLanguageAriaLabel: 'Select language',
|
|
@@ -29,7 +31,7 @@ exports.DEFAULT_LOCALE_OPTIONS = {
|
|
|
29
31
|
backToHome: 'Take me home',
|
|
30
32
|
// a11y
|
|
31
33
|
openInNewWindow: 'open in new window',
|
|
32
|
-
|
|
34
|
+
toggleColorMode: 'toggle color mode',
|
|
33
35
|
toggleSidebar: 'toggle sidebar',
|
|
34
36
|
};
|
|
35
37
|
exports.DEFAULT_LOCALE_DATA = {
|
package/lib/shared/options.d.ts
CHANGED
|
@@ -45,6 +45,18 @@ export interface DefaultThemePluginsOptions {
|
|
|
45
45
|
export declare type DefaultThemeLocaleOptions = DefaultThemeData;
|
|
46
46
|
export declare type DefaultThemeData = ThemeData<DefaultThemeLocaleData>;
|
|
47
47
|
export interface DefaultThemeLocaleData extends LocaleData {
|
|
48
|
+
/**
|
|
49
|
+
* Default color mode
|
|
50
|
+
*
|
|
51
|
+
* @default 'auto'
|
|
52
|
+
*/
|
|
53
|
+
colorMode?: 'auto' | 'dark' | 'light';
|
|
54
|
+
/**
|
|
55
|
+
* Enable color mode switching and display a button in navbar or not
|
|
56
|
+
*
|
|
57
|
+
* @default true
|
|
58
|
+
*/
|
|
59
|
+
colorModeSwitch?: boolean;
|
|
48
60
|
/**
|
|
49
61
|
* Home path of current locale
|
|
50
62
|
*
|
|
@@ -69,12 +81,6 @@ export interface DefaultThemeLocaleData extends LocaleData {
|
|
|
69
81
|
* Logo to display in navbar in dark mode
|
|
70
82
|
*/
|
|
71
83
|
logoDark?: null | string;
|
|
72
|
-
/**
|
|
73
|
-
* Navbar dark mode button config
|
|
74
|
-
*
|
|
75
|
-
* Enable dark mode switching and display a button in navbar or not
|
|
76
|
-
*/
|
|
77
|
-
darkMode?: boolean;
|
|
78
84
|
/**
|
|
79
85
|
* Navbar repository config
|
|
80
86
|
*
|
|
@@ -227,9 +233,9 @@ export interface DefaultThemeLocaleData extends LocaleData {
|
|
|
227
233
|
*/
|
|
228
234
|
openInNewWindow?: string;
|
|
229
235
|
/**
|
|
230
|
-
* A11y text for
|
|
236
|
+
* A11y text for color mode toggle button
|
|
231
237
|
*/
|
|
232
|
-
|
|
238
|
+
toggleColorMode?: string;
|
|
233
239
|
/**
|
|
234
240
|
* A11y text for sidebar toggle button
|
|
235
241
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/theme-default",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.48",
|
|
4
4
|
"description": "Default theme of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress-theme",
|
|
@@ -25,27 +25,27 @@
|
|
|
25
25
|
"templates"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@vuepress/client": "2.0.0-beta.
|
|
29
|
-
"@vuepress/core": "2.0.0-beta.
|
|
30
|
-
"@vuepress/plugin-active-header-links": "2.0.0-beta.
|
|
31
|
-
"@vuepress/plugin-back-to-top": "2.0.0-beta.
|
|
32
|
-
"@vuepress/plugin-container": "2.0.0-beta.
|
|
33
|
-
"@vuepress/plugin-external-link-icon": "2.0.0-beta.
|
|
34
|
-
"@vuepress/plugin-git": "2.0.0-beta.
|
|
35
|
-
"@vuepress/plugin-medium-zoom": "2.0.0-beta.
|
|
36
|
-
"@vuepress/plugin-nprogress": "2.0.0-beta.
|
|
37
|
-
"@vuepress/plugin-palette": "2.0.0-beta.
|
|
38
|
-
"@vuepress/plugin-prismjs": "2.0.0-beta.
|
|
39
|
-
"@vuepress/plugin-theme-data": "2.0.0-beta.
|
|
40
|
-
"@vuepress/shared": "2.0.0-beta.
|
|
41
|
-
"@vuepress/utils": "2.0.0-beta.
|
|
42
|
-
"@vueuse/core": "^8.
|
|
43
|
-
"sass": "^1.
|
|
44
|
-
"vue": "^3.2.
|
|
28
|
+
"@vuepress/client": "2.0.0-beta.48",
|
|
29
|
+
"@vuepress/core": "2.0.0-beta.48",
|
|
30
|
+
"@vuepress/plugin-active-header-links": "2.0.0-beta.48",
|
|
31
|
+
"@vuepress/plugin-back-to-top": "2.0.0-beta.48",
|
|
32
|
+
"@vuepress/plugin-container": "2.0.0-beta.48",
|
|
33
|
+
"@vuepress/plugin-external-link-icon": "2.0.0-beta.48",
|
|
34
|
+
"@vuepress/plugin-git": "2.0.0-beta.48",
|
|
35
|
+
"@vuepress/plugin-medium-zoom": "2.0.0-beta.48",
|
|
36
|
+
"@vuepress/plugin-nprogress": "2.0.0-beta.48",
|
|
37
|
+
"@vuepress/plugin-palette": "2.0.0-beta.48",
|
|
38
|
+
"@vuepress/plugin-prismjs": "2.0.0-beta.48",
|
|
39
|
+
"@vuepress/plugin-theme-data": "2.0.0-beta.48",
|
|
40
|
+
"@vuepress/shared": "2.0.0-beta.48",
|
|
41
|
+
"@vuepress/utils": "2.0.0-beta.48",
|
|
42
|
+
"@vueuse/core": "^8.5.0",
|
|
43
|
+
"sass": "^1.52.1",
|
|
44
|
+
"vue": "^3.2.36",
|
|
45
45
|
"vue-router": "^4.0.15"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"sass-loader": "^
|
|
48
|
+
"sass-loader": "^13.0.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependenciesMeta": {
|
|
51
51
|
"sass-loader": {
|