@vuepress/theme-default 2.0.0-rc.38 → 2.0.0-rc.39

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.
@@ -9,4 +9,3 @@ export declare const useDarkMode: () => DarkModeRef;
9
9
  * Create dark mode ref and provide as global computed in setup
10
10
  */
11
11
  export declare const setupDarkMode: () => void;
12
- export declare const updateHtmlDarkClass: (isDarkMode: DarkModeRef) => void;
@@ -2,6 +2,18 @@ import { useThemeLocaleData } from '@theme/useThemeData';
2
2
  import { usePreferredDark, useStorage } from '@vueuse/core';
3
3
  import { computed, inject, onMounted, onUnmounted, provide, watch } from 'vue';
4
4
  export const darkModeSymbol = Symbol(__VUEPRESS_DEV__ ? 'darkMode' : '');
5
+ const applyDarkmodeToHTML = (isDarkMode) => {
6
+ const update = (value = isDarkMode.value) => {
7
+ // set `class="dark"` on `<html>` element
8
+ const el = window.document.documentElement;
9
+ el.classList.toggle('dark', value);
10
+ el.dataset.theme = value ? 'dark' : 'light';
11
+ };
12
+ onMounted(() => {
13
+ watch(isDarkMode, update, { immediate: true });
14
+ });
15
+ onUnmounted(() => update());
16
+ };
5
17
  /**
6
18
  * Inject dark mode global computed
7
19
  */
@@ -42,16 +54,5 @@ export const setupDarkMode = () => {
42
54
  },
43
55
  });
44
56
  provide(darkModeSymbol, isDarkMode);
45
- updateHtmlDarkClass(isDarkMode);
46
- };
47
- export const updateHtmlDarkClass = (isDarkMode) => {
48
- const update = (value = isDarkMode.value) => {
49
- // set `class="dark"` on `<html>` element
50
- const htmlEl = window?.document.querySelector('html');
51
- htmlEl?.classList.toggle('dark', value);
52
- };
53
- onMounted(() => {
54
- watch(isDarkMode, update, { immediate: true });
55
- });
56
- onUnmounted(() => update());
57
+ applyDarkmodeToHTML(isDarkMode);
57
58
  };
@@ -1,247 +1,23 @@
1
- /* stylelint-disable no-duplicate-selectors */
2
- /* stylelint-disable scss/comment-no-empty */
3
1
  @import '../variables';
4
2
 
5
- // the original font-size is 14px, 1.7 will make line-height be 23.8px
6
- $line-height: 1.7;
7
-
8
- pre[class*='language-'] {
9
- overflow: auto;
10
-
11
- margin: 0.5em 0;
12
-
13
- font-size: 1em;
14
- font-family: var(--font-family-code);
15
- line-height: 1.5;
16
- }
17
-
18
- // ===============================
19
- // Forked and modified from prismjs/themes/prism-tomorrow.css
20
-
21
- pre[class*='language-'] {
22
- background: #2d2d2d;
23
- color: #ccc;
24
- }
25
-
26
- .token.comment,
27
- .token.block-comment,
28
- .token.prolog,
29
- .token.doctype,
30
- .token.cdata {
31
- color: #999;
32
- }
33
-
34
- .token.punctuation {
35
- color: #ccc;
36
- }
37
-
38
- .token.tag,
39
- .token.attr-name,
40
- .token.namespace,
41
- .token.deleted {
42
- color: #ec5975;
43
- }
44
-
45
- .token.function-name {
46
- color: #6196cc;
47
- }
48
-
49
- .token.boolean,
50
- .token.number,
51
- .token.function {
52
- color: #f08d49;
53
- }
54
-
55
- .token.property,
56
- .token.class-name,
57
- .token.constant,
58
- .token.symbol {
59
- color: #f8c555;
60
- }
61
-
62
- .token.selector,
63
- .token.important,
64
- .token.atrule,
65
- .token.keyword,
66
- .token.builtin {
67
- color: #cc99cd;
68
- }
69
-
70
- .token.string,
71
- .token.char,
72
- .token.attr-value,
73
- .token.regex,
74
- .token.variable {
75
- color: #7ec699;
76
- }
77
-
78
- .token.operator,
79
- .token.entity,
80
- .token.url {
81
- color: #67cdcc;
82
- }
83
-
84
- .token.important,
85
- .token.bold {
86
- font-weight: bold;
87
- }
88
-
89
- .token.italic {
90
- font-style: italic;
91
- }
92
-
93
- .token.entity {
94
- cursor: help;
95
- }
96
-
97
- .token.inserted {
98
- color: #3eaf7c;
99
- }
100
-
101
- // ===============================
102
-
103
- .theme-default-content {
104
- pre,
105
- pre[class*='language-'] {
106
- overflow: auto;
107
- margin: 0.85rem 0;
108
- border-radius: 6px;
109
- line-height: $line-height;
110
-
111
- code {
112
- display: block;
113
-
114
- box-sizing: border-box;
115
- width: fit-content;
116
- min-width: 100%;
117
- padding: 1.3rem 1.5rem;
118
- border-radius: 0;
119
-
120
- background-color: transparent !important;
121
- color: #fff;
122
-
123
- overflow-wrap: unset;
124
-
125
- -webkit-font-smoothing: auto;
126
- -moz-osx-font-smoothing: auto;
127
- }
128
- }
129
-
130
- .line-number {
131
- font-family: var(--font-family-code);
132
- }
133
- }
134
-
3
+ // code block additional styles
135
4
  div[class*='language-'] {
136
- position: relative;
137
- border-radius: 6px;
138
- background-color: var(--code-bg-color);
139
-
140
- &::before {
141
- content: attr(data-title);
142
-
143
- position: absolute;
144
- top: 0.8em;
145
- right: 1em;
146
- z-index: 3;
147
-
148
- color: var(--code-line-number-color);
149
-
150
- font-size: 0.75rem;
151
- }
152
-
153
- pre,
154
- pre[class*='language-'] {
155
- position: relative;
156
- z-index: 1;
157
-
158
- // force override the background color to be compatible with shiki
159
- background: transparent !important;
160
- }
161
-
162
- &:not(.line-numbers-mode) {
163
- .line-numbers {
164
- display: none;
165
- }
166
- }
167
-
168
- &.line-numbers-mode {
169
- pre {
170
- vertical-align: middle;
171
- margin-left: var(--code-line-number-wrapper-width);
172
- }
173
-
174
- code {
175
- padding-left: 1rem;
176
- }
177
-
178
- .line-numbers {
179
- counter-reset: line-number;
180
-
181
- position: absolute;
182
- top: 0;
183
-
184
- width: var(--code-line-number-wrapper-width);
185
- padding-top: 1.3rem;
186
-
187
- color: var(--code-line-number-color);
188
-
189
- font-size: 0.875em;
190
- line-height: $line-height;
191
- text-align: center;
192
-
193
- .line-number {
194
- position: relative;
195
- z-index: 3;
196
- user-select: none;
197
-
198
- /* stylelint-disable-next-line max-nesting-depth */
199
- &::before {
200
- content: counter(line-number);
201
- counter-increment: line-number;
202
- }
203
- }
204
- }
205
-
206
- &::after {
207
- content: '';
5
+ margin: 0.75rem 0;
6
+ transition:
7
+ background-color var(--t-color),
8
+ color var(--t-color);
208
9
 
209
- position: absolute;
210
- top: 0;
211
- left: 0;
10
+ @media (max-width: $MQMobileNarrow) {
11
+ --code-border-radius: 0;
212
12
 
213
- width: var(--code-line-number-wrapper-width);
214
- height: 100%;
215
- border-right: 1px solid var(--code-highlight-bg-color);
216
- border-radius: 6px 0 0 6px;
217
- }
218
- }
219
- }
220
-
221
- // ------------ plugin-shiki code highlighting ------------
222
- div[data-highlighter='shiki'] {
223
- background-color: var(--shiki-light-bg, var(--code-bg-color));
224
- transition: background-color var(--t-color);
225
-
226
- .dark & {
227
- background-color: var(--shiki-dark-bg, var(--code-bg-color));
13
+ margin: 0.75rem -1.5rem;
228
14
  }
229
- }
230
-
231
- .shiki span {
232
- color: var(--shiki-light, inherit);
233
-
234
- .dark & {
235
- color: var(--shiki-dark, inherit);
236
- }
237
- }
238
15
 
239
- // narrow mobile
240
- @media (max-width: $MQMobileNarrow) {
241
- .theme-default-content {
242
- div[class*='language-'] {
243
- margin: 0.85rem -1.5rem;
244
- border-radius: 0;
16
+ // transitions for code notation highlighting
17
+ .line {
18
+ &.diff,
19
+ &.highlighted {
20
+ transition: background-color var(--t-color);
245
21
  }
246
22
  }
247
23
  }
@@ -1,5 +1,4 @@
1
1
  @use 'normalize';
2
2
  @use 'code';
3
- @use 'code-notation';
4
3
  @use 'custom-container';
5
4
  @use 'toc';
@@ -26,7 +26,7 @@ a {
26
26
  code {
27
27
  background-color: var(--c-bg-light);
28
28
  color: var(--c-text-lighter);
29
- font-family: var(--font-family-code);
29
+ font-family: var(--code-font-family);
30
30
  transition: background-color var(--t-color);
31
31
 
32
32
  p a & {
@@ -52,9 +52,6 @@ html.dark {
52
52
  --c-badge-danger: var(--c-danger);
53
53
  --c-badge-danger-text: #401416;
54
54
 
55
- // code blocks vars
56
- --code-hl-bg-color: #363b46;
57
-
58
55
  // plugin-docsearch
59
56
  /* stylelint-disable-next-line selector-class-pattern */
60
57
  .DocSearch {
@@ -72,24 +72,9 @@
72
72
  --t-color: 0.3s ease;
73
73
  --t-transform: 0.3s ease;
74
74
 
75
- // code blocks vars
76
- --code-bg-color: #282c34;
77
- --code-highlight-bg-color: rgb(0 0 0 / 66%);
78
- --code-highlight-error-bg-color: rgb(244 63 94 / 16%);
79
- --code-highlight-warning-bg-color: rgb(255 193 7 / 16%);
80
- --code-line-diff-remove-color: rgb(244 63 94 / 16%);
81
- --code-line-diff-remove-symbol-color: #e0575b;
82
- --code-line-diff-add-color: rgb(16 185 129 / 16%);
83
- --code-line-diff-add-symbol-color: #298459;
84
- --code-word-highlight-bg-color: rgb(0 0 0 / 20%);
85
- --code-word-highlight-border: #636363;
86
- --code-line-number-color: #9e9e9e;
87
- --code-line-number-wrapper-width: 3.5rem;
88
-
89
75
  // font vars
90
76
  --font-family: -apple-system, 'BlinkMacSystemFont', 'Segoe UI', roboto, oxygen,
91
77
  ubuntu, cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
92
- --font-family-code: consolas, monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
93
78
 
94
79
  // layout vars
95
80
  --navbar-height: 3.6rem;
@@ -1,4 +1,4 @@
1
- import { addViteOptimizeDepsExclude, chainWebpack } from '@vuepress/helper';
1
+ import { addViteConfig, addViteOptimizeDepsExclude, chainWebpack, } from '@vuepress/helper';
2
2
  import { activeHeaderLinksPlugin } from '@vuepress/plugin-active-header-links';
3
3
  import { backToTopPlugin } from '@vuepress/plugin-back-to-top';
4
4
  import { copyCodePlugin } from '@vuepress/plugin-copy-code';
@@ -41,6 +41,31 @@ export const defaultTheme = ({ hostname, themePlugins = {}, ...localeOptions } =
41
41
  },
42
42
  clientConfigFile: path.resolve(__dirname, '../client/config.js'),
43
43
  extendsBundlerOptions: (bundlerOptions, app) => {
44
+ // FIXME: hide sass deprecation warning for mixed-decls
45
+ addViteConfig(bundlerOptions, app, {
46
+ css: {
47
+ preprocessorOptions: {
48
+ sass: {
49
+ logger: {
50
+ warn: (message, { deprecation, deprecationType }) => {
51
+ if (deprecation && deprecationType.id === 'mixed-decls')
52
+ return;
53
+ console.warn(message);
54
+ },
55
+ },
56
+ },
57
+ scss: {
58
+ logger: {
59
+ warn: (message, { deprecation, deprecationType }) => {
60
+ if (deprecation && deprecationType.id === 'mixed-decls')
61
+ return;
62
+ console.warn(message);
63
+ },
64
+ },
65
+ },
66
+ },
67
+ },
68
+ });
44
69
  chainWebpack(bundlerOptions, app, (config) => {
45
70
  config.module
46
71
  .rule('scss')
@@ -54,6 +79,7 @@ export const defaultTheme = ({ hostname, themePlugins = {}, ...localeOptions } =
54
79
  },
55
80
  }));
56
81
  });
82
+ // ensure theme alias is not optimized by Vite
57
83
  addViteOptimizeDepsExclude(bundlerOptions, app, '@theme');
58
84
  },
59
85
  extendsPage: (page) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/theme-default",
3
- "version": "2.0.0-rc.38",
3
+ "version": "2.0.0-rc.39",
4
4
  "description": "Default theme of VuePress",
5
5
  "keywords": [
6
6
  "vuepress-theme",
@@ -37,23 +37,23 @@
37
37
  "templates"
38
38
  ],
39
39
  "dependencies": {
40
- "@vuepress/helper": "2.0.0-rc.38",
41
- "@vuepress/plugin-active-header-links": "2.0.0-rc.38",
42
- "@vuepress/plugin-back-to-top": "2.0.0-rc.38",
43
- "@vuepress/plugin-copy-code": "2.0.0-rc.38",
40
+ "@vuepress/helper": "2.0.0-rc.39",
41
+ "@vuepress/plugin-active-header-links": "2.0.0-rc.39",
42
+ "@vuepress/plugin-back-to-top": "2.0.0-rc.39",
43
+ "@vuepress/plugin-copy-code": "2.0.0-rc.39",
44
44
  "@vuepress/plugin-git": "2.0.0-rc.38",
45
- "@vuepress/plugin-links-check": "2.0.0-rc.38",
45
+ "@vuepress/plugin-links-check": "2.0.0-rc.39",
46
46
  "@vuepress/plugin-markdown-container": "2.0.0-rc.37",
47
- "@vuepress/plugin-medium-zoom": "2.0.0-rc.38",
48
- "@vuepress/plugin-nprogress": "2.0.0-rc.38",
47
+ "@vuepress/plugin-medium-zoom": "2.0.0-rc.39",
48
+ "@vuepress/plugin-nprogress": "2.0.0-rc.39",
49
49
  "@vuepress/plugin-palette": "2.0.0-rc.37",
50
- "@vuepress/plugin-prismjs": "2.0.0-rc.37",
51
- "@vuepress/plugin-seo": "2.0.0-rc.38",
52
- "@vuepress/plugin-sitemap": "2.0.0-rc.38",
53
- "@vuepress/plugin-theme-data": "2.0.0-rc.38",
50
+ "@vuepress/plugin-prismjs": "2.0.0-rc.39",
51
+ "@vuepress/plugin-seo": "2.0.0-rc.39",
52
+ "@vuepress/plugin-sitemap": "2.0.0-rc.39",
53
+ "@vuepress/plugin-theme-data": "2.0.0-rc.39",
54
54
  "@vueuse/core": "^10.11.0",
55
55
  "sass": "^1.77.8",
56
- "vue": "^3.4.31"
56
+ "vue": "^3.4.32"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "sass-loader": "^14.0.0",
@@ -67,5 +67,5 @@
67
67
  "publishConfig": {
68
68
  "access": "public"
69
69
  },
70
- "gitHead": "4345344b92c788c8f0c4a78b2cd022bc31ef5108"
70
+ "gitHead": "5fc0740210318a083a02e8bfcd31fdde5b2f88ac"
71
71
  }
@@ -23,8 +23,12 @@
23
23
  const systemDarkMode =
24
24
  window.matchMedia &&
25
25
  window.matchMedia('(prefers-color-scheme: dark)').matches
26
- if (userMode === 'dark' || (userMode !== 'light' && systemDarkMode)) {
26
+
27
+ if (userMode === 'light') {
28
+ document.documentElement.dataset.theme = 'light'
29
+ } else if (userMode === 'dark' || systemDarkMode) {
27
30
  document.documentElement.classList.toggle('dark', true)
31
+ document.documentElement.dataset.theme = 'dark'
28
32
  }
29
33
  </script>
30
34
  <!--vuepress-ssr-head-->
@@ -1,125 +0,0 @@
1
- // ------------ code notation highlighting ------------
2
- // matches `<span class="line xxxx" ></span>`
3
-
4
- div[class*='language-'] {
5
- // highlight lines and notation highlight
6
- // `!code highlight` and `!code hl` are the same:
7
- // - `// [\!code highlight]`
8
- // - `// [\!code hl]`
9
- // - `// [\!code highlight:3]`
10
- // - `// [\!code hl:3]`
11
- // It also has the style of error level,
12
- // covering the background color with 'warning' and 'error' classes.
13
- // - `// [\!code warning]`
14
- // - `// [\!code error]`
15
- // - `// [\!code warning:3]`
16
- // - `// [\!code error:3]`
17
- .line.highlighted {
18
- display: inline-block;
19
-
20
- width: 100%;
21
- margin: 0 -24px;
22
- padding: 0 24px;
23
-
24
- background-color: var(--code-highlight-bg-color);
25
-
26
- transition: background-color 0.5s;
27
-
28
- &.error {
29
- background-color: var(--code-highlight-error-bg-color);
30
- }
31
-
32
- &.warning {
33
- background-color: var(--code-highlight-warning-bg-color);
34
- }
35
- }
36
-
37
- // notation diff line
38
- // - class="diff add": `// [\!code ++]` or `// [\!code ++:3]`
39
- // - class="diff remove": `// [\!code --]` or `// [\!code --:3]`
40
- .line.diff {
41
- display: inline-block;
42
-
43
- width: 100%;
44
- margin: 0 -24px;
45
- padding: 0 24px;
46
-
47
- transition: background-color 0.5s;
48
-
49
- &::before {
50
- position: absolute;
51
- left: 10px;
52
- }
53
-
54
- &.remove {
55
- background-color: var(--code-line-diff-remove-color);
56
- opacity: 0.7;
57
-
58
- &::before {
59
- content: '-';
60
- color: var(--code-line-diff-remove-symbol-color);
61
- }
62
- }
63
-
64
- &.add {
65
- background-color: var(--code-line-diff-add-color);
66
-
67
- &::before {
68
- content: '+';
69
- color: var(--code-line-diff-add-symbol-color);
70
- }
71
- }
72
- }
73
-
74
- &.line-numbers-mode .line.diff::before {
75
- left: 4px;
76
- }
77
-
78
- // notation focused lines
79
- // - `// [\!code focus]`
80
- // - `// [\!code focus:3]`
81
- .has-focused-lines .line:not(.has-focus) {
82
- opacity: 0.7;
83
- filter: blur(0.095rem);
84
- transition:
85
- filter 0.35s,
86
- opacity 0.35s;
87
- }
88
-
89
- &:hover .has-focused-lines .line:not(.has-focus) {
90
- opacity: 1;
91
- filter: blur(0);
92
- }
93
-
94
- // notation word highlight
95
- // - `// [\!code word:xxx]`
96
- // - `// [\!code word:xxx:3]`
97
- .highlighted-word {
98
- margin: -1px -2px;
99
- padding: 1px 2px;
100
- border: solid 1px var(--code-word-highlight-border);
101
- border-radius: 4px;
102
-
103
- background-color: var(--code-word-highlight-bg-color);
104
- }
105
-
106
- // whitespace
107
- .tab,
108
- .space {
109
- position: relative;
110
- }
111
-
112
- .tab::before,
113
- .space::before {
114
- position: absolute;
115
- opacity: 0.3;
116
- }
117
-
118
- .tab::before {
119
- content: '⇥';
120
- }
121
-
122
- .space::before {
123
- content: '·';
124
- }
125
- }