@vuepress/theme-default 2.0.0-beta.46 → 2.0.0-beta.47
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/PageMeta.vue +1 -5
- package/lib/client/components/{ToggleDarkModeButton.vue → ToggleColorModeButton.vue} +4 -4
- package/lib/client/composables/useDarkMode.js +4 -4
- package/lib/client/layouts/Layout.vue +1 -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/page.scss +5 -0
- package/lib/node/utils/assignDefaultLocaleOptions.js +4 -2
- package/lib/shared/options.d.ts +14 -8
- package/package.json +18 -18
|
@@ -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 {
|
|
@@ -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"
|
|
@@ -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') {
|
|
@@ -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 {
|
|
@@ -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.47",
|
|
4
4
|
"description": "Default theme of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress-theme",
|
|
@@ -25,23 +25,23 @@
|
|
|
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.47",
|
|
29
|
+
"@vuepress/core": "2.0.0-beta.47",
|
|
30
|
+
"@vuepress/plugin-active-header-links": "2.0.0-beta.47",
|
|
31
|
+
"@vuepress/plugin-back-to-top": "2.0.0-beta.47",
|
|
32
|
+
"@vuepress/plugin-container": "2.0.0-beta.47",
|
|
33
|
+
"@vuepress/plugin-external-link-icon": "2.0.0-beta.47",
|
|
34
|
+
"@vuepress/plugin-git": "2.0.0-beta.47",
|
|
35
|
+
"@vuepress/plugin-medium-zoom": "2.0.0-beta.47",
|
|
36
|
+
"@vuepress/plugin-nprogress": "2.0.0-beta.47",
|
|
37
|
+
"@vuepress/plugin-palette": "2.0.0-beta.47",
|
|
38
|
+
"@vuepress/plugin-prismjs": "2.0.0-beta.47",
|
|
39
|
+
"@vuepress/plugin-theme-data": "2.0.0-beta.47",
|
|
40
|
+
"@vuepress/shared": "2.0.0-beta.47",
|
|
41
|
+
"@vuepress/utils": "2.0.0-beta.47",
|
|
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": {
|