@vuepress/theme-default 2.0.0-rc.30 → 2.0.0-rc.32

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.
@@ -1,12 +1,12 @@
1
1
  import { useEventListener } from '@vueuse/core';
2
2
  import { onMounted } from 'vue';
3
- import cssVars from '../styles/_variables.module.scss?module';
3
+ import cssVariables from '../styles/_variables.module.scss';
4
4
  export var DeviceType;
5
5
  (function (DeviceType) {
6
6
  DeviceType["MOBILE"] = "mobile";
7
7
  })(DeviceType || (DeviceType = {}));
8
8
  const DeviceTypeMap = {
9
- [DeviceType.MOBILE]: Number.parseInt(cssVars.mobile?.replace('px', ''), 10),
9
+ [DeviceType.MOBILE]: Number.parseInt(cssVariables.mobile.replace('px', ''), 10),
10
10
  };
11
11
  /**
12
12
  * add listener to detect screen though device type
@@ -62,7 +62,9 @@ const onTouchEnd = (e): void => {
62
62
  // external-link-icon
63
63
  const enableExternalLinkIcon = computed(
64
64
  () =>
65
- frontmatter.value.externalLinkIcon ?? themeLocale.externalLinkIcon ?? true,
65
+ frontmatter.value.externalLinkIcon ??
66
+ themeLocale.value.externalLinkIcon ??
67
+ true,
66
68
  )
67
69
 
68
70
  // classes
@@ -4,7 +4,7 @@ declare module '*.vue' {
4
4
  export default comp
5
5
  }
6
6
 
7
- declare module '*.module.scss?module' {
8
- const cssVars: Record<string, string>
9
- export default cssVars
7
+ declare module '*/styles/_variables.module.scss' {
8
+ const cSSVariables: Record<string, string>
9
+ export default cSSVariables
10
10
  }
@@ -1,8 +1,7 @@
1
1
  @import '_variables';
2
2
 
3
- // Safari only support integer pixel value for line-height
4
- // the original font-size is 16px, 1.375 will make line-height be 22px
5
- $line-height: 1.375;
3
+ // the original font-size is 14px, 1.7 will make line-height be 23.8px
4
+ $line-height: 1.7;
6
5
 
7
6
  // ===============================
8
7
  // Forked and modified from prismjs/themes/prism-tomorrow.css
@@ -32,7 +31,6 @@ pre[class*='language-'] {
32
31
 
33
32
  /* Code blocks */
34
33
  pre[class*='language-'] {
35
- padding: 1em;
36
34
  margin: 0.5em 0;
37
35
  overflow: auto;
38
36
  }
@@ -129,14 +127,17 @@ pre[class*='language-'] {
129
127
  pre,
130
128
  pre[class*='language-'] {
131
129
  line-height: $line-height;
132
- padding: 1.3rem 1.5rem;
133
130
  margin: 0.85rem 0;
134
131
  border-radius: 6px;
135
132
  overflow: auto;
136
133
 
137
134
  code {
135
+ box-sizing: border-box;
138
136
  color: #fff;
139
- padding: 0;
137
+ padding: 1.3rem 1.5rem;
138
+ display: block;
139
+ width: fit-content;
140
+ min-width: 100%;
140
141
  background-color: transparent !important;
141
142
  border-radius: 0;
142
143
  overflow-wrap: unset;
@@ -180,6 +181,7 @@ div[class*='language-'] {
180
181
  top: 0;
181
182
  left: 0;
182
183
  width: 100%;
184
+ font-size: 0.875em;
183
185
  line-height: $line-height;
184
186
 
185
187
  .highlight-line {
@@ -211,17 +213,21 @@ div[class*='language-'] {
211
213
 
212
214
  pre {
213
215
  margin-left: var(--code-ln-wrapper-width);
214
- padding-left: 1rem;
215
216
  vertical-align: middle;
216
217
  }
217
218
 
219
+ code {
220
+ padding-left: 1rem;
221
+ }
222
+
218
223
  .line-numbers {
219
224
  position: absolute;
220
225
  top: 0;
221
226
  width: var(--code-ln-wrapper-width);
222
227
  text-align: center;
223
228
  color: var(--code-ln-color);
224
- padding-top: 1.25rem;
229
+ padding-top: 1.3rem;
230
+ font-size: 0.875em;
225
231
  line-height: $line-height;
226
232
  counter-reset: line-number;
227
233
 
@@ -234,7 +240,6 @@ div[class*='language-'] {
234
240
  &::before {
235
241
  counter-increment: line-number;
236
242
  content: counter(line-number);
237
- font-size: 0.85em;
238
243
  }
239
244
  }
240
245
  }
@@ -252,6 +257,97 @@ div[class*='language-'] {
252
257
  }
253
258
  }
254
259
 
260
+ // ------------ code notation highlighting ------------
261
+ // matches `<span class="line xxxx" ></span>`
262
+
263
+ div[class*='language-'] pre {
264
+ // highlight lines and notation highlight
265
+ //
266
+ // `!code highlight` and `!code hl` are the same:
267
+ // - `// [\!code highlight]`
268
+ // - `// [\!code hl]`
269
+ // - `// [\!code highlight:3]`
270
+ // - `// [\!code hl:3]`
271
+ //
272
+ // It also has the style of error level,
273
+ // covering the background color with 'warning' and 'error' classes.
274
+ // - `// [\!code warning]`
275
+ // - `// [\!code error]`
276
+ // - `// [\!code warning:3]`
277
+ // - `// [\!code error:3]`
278
+ code .highlighted {
279
+ background-color: var(--code-hl-bg-color);
280
+ transition: background-color 0.5s;
281
+ margin: 0 -24px;
282
+ padding: 0 24px;
283
+ width: 100%;
284
+ display: inline-block;
285
+
286
+ &.error {
287
+ background-color: var(--code-hl-error-bg-color);
288
+ }
289
+
290
+ &.warning {
291
+ background-color: var(--code-hl-warning-bg-color);
292
+ }
293
+ }
294
+
295
+ // notation diff line
296
+ //
297
+ // - class="diff add": `// [\!code ++]` or `// [\!code ++:3]`
298
+ // - class="diff remove": `// [\!code --]` or `// [\!code --:3]`
299
+ code .diff {
300
+ transition: background-color 0.5s;
301
+ margin: 0 -24px;
302
+ padding: 0 24px;
303
+ width: 100%;
304
+ display: inline-block;
305
+
306
+ &::before {
307
+ position: absolute;
308
+ left: 10px;
309
+ }
310
+
311
+ &.remove {
312
+ background-color: var(--code-line-diff-remove-color);
313
+ opacity: 0.7;
314
+
315
+ &::before {
316
+ content: '-';
317
+ color: var(--code-line-diff-remove-symbol-color);
318
+ }
319
+ }
320
+
321
+ &.add {
322
+ background-color: var(--code-line-diff-add-color);
323
+
324
+ &::before {
325
+ content: '+';
326
+ color: var(--code-line-diff-add-symbol-color);
327
+ }
328
+ }
329
+ }
330
+ }
331
+
332
+ // notation focused lines
333
+ //
334
+ // - `// [\!code focus]`
335
+ // - `// [\!code focus:3]`
336
+ div[class*='language-'] {
337
+ .has-focused-lines .line:not(.has-focus) {
338
+ filter: blur(0.095rem);
339
+ opacity: 0.7;
340
+ transition:
341
+ filter 0.35s,
342
+ opacity 0.35s;
343
+ }
344
+
345
+ &:hover .has-focused-lines .line:not(.has-focus) {
346
+ filter: blur(0);
347
+ opacity: 1;
348
+ }
349
+ }
350
+
255
351
  // narrow mobile
256
352
  @media (max-width: $MQMobileNarrow) {
257
353
  .theme-default-content {
@@ -49,7 +49,7 @@ code {
49
49
  color: var(--c-text-lighter);
50
50
  padding: 0.25rem 0.5rem;
51
51
  margin: 0;
52
- font-size: 0.85em;
52
+ font-size: 0.875em;
53
53
  background-color: var(--c-bg-light);
54
54
  border-radius: 3px;
55
55
  overflow-wrap: break-word;
@@ -75,6 +75,12 @@
75
75
  // code blocks vars
76
76
  --code-bg-color: #282c34;
77
77
  --code-hl-bg-color: rgba(0, 0, 0, 0.66);
78
+ --code-hl-error-bg-color: rgba(244, 63, 94, 0.16);
79
+ --code-hl-warning-bg-color: rgba(255, 193, 7, 0.16);
80
+ --code-line-diff-remove-color: rgba(244, 63, 94, 0.16);
81
+ --code-line-diff-remove-symbol-color: #e0575b;
82
+ --code-line-diff-add-color: rgba(16, 185, 129, 0.16);
83
+ --code-line-diff-add-symbol-color: #298459;
78
84
  --code-ln-color: #9e9e9e;
79
85
  --code-ln-wrapper-width: 3.5rem;
80
86
 
@@ -118,7 +118,9 @@ export const defaultTheme = ({ hostname, themePlugins = {}, ...localeOptions } =
118
118
  // @vuepress/plugin-palette
119
119
  palettePlugin({ preset: 'sass' }),
120
120
  // @vuepress/plugin-prismjs
121
- themePlugins.prismjs !== false ? prismjsPlugin() : [],
121
+ themePlugins.prismjs !== false
122
+ ? prismjsPlugin(isPlainObject(themePlugins.prismjs) ? themePlugins.prismjs : {})
123
+ : [],
122
124
  // @vuepress/plugin-seo
123
125
  hostname && themePlugins.seo !== false
124
126
  ? seoPlugin({
@@ -1,6 +1,7 @@
1
1
  import type { BackToTopPluginOptions } from '@vuepress/plugin-back-to-top';
2
2
  import type { CopyCodePluginOptions } from '@vuepress/plugin-copy-code';
3
3
  import type { LinksCheckPluginOptions } from '@vuepress/plugin-links-check';
4
+ import type { PrismjsPluginOptions } from '@vuepress/plugin-prismjs';
4
5
  import type { SeoPluginOptions } from '@vuepress/plugin-seo';
5
6
  import type { SitemapPluginOptions } from '@vuepress/plugin-sitemap';
6
7
  import type { ThemeData } from '@vuepress/plugin-theme-data';
@@ -49,7 +50,7 @@ export interface DefaultThemePluginsOptions {
49
50
  /**
50
51
  * Enable @vuepress/plugin-prismjs or not
51
52
  */
52
- prismjs?: boolean;
53
+ prismjs?: boolean | PrismjsPluginOptions;
53
54
  /**
54
55
  * Enable @vuepress/plugin-seo or not
55
56
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/theme-default",
3
- "version": "2.0.0-rc.30",
3
+ "version": "2.0.0-rc.32",
4
4
  "description": "Default theme of VuePress",
5
5
  "keywords": [
6
6
  "vuepress-theme",
@@ -42,27 +42,27 @@
42
42
  "copy": "cpx \"src/**/*.{d.ts,vue,scss}\" lib"
43
43
  },
44
44
  "dependencies": {
45
- "@vuepress/helper": "~2.0.0-rc.30",
46
- "@vuepress/plugin-active-header-links": "~2.0.0-rc.30",
47
- "@vuepress/plugin-back-to-top": "~2.0.0-rc.30",
48
- "@vuepress/plugin-copy-code": "~2.0.0-rc.30",
49
- "@vuepress/plugin-git": "~2.0.0-rc.30",
50
- "@vuepress/plugin-links-check": "~2.0.0-rc.30",
51
- "@vuepress/plugin-markdown-container": "~2.0.0-rc.30",
52
- "@vuepress/plugin-medium-zoom": "~2.0.0-rc.30",
53
- "@vuepress/plugin-nprogress": "~2.0.0-rc.30",
54
- "@vuepress/plugin-palette": "~2.0.0-rc.30",
55
- "@vuepress/plugin-prismjs": "~2.0.0-rc.30",
56
- "@vuepress/plugin-seo": "~2.0.0-rc.30",
57
- "@vuepress/plugin-sitemap": "~2.0.0-rc.30",
58
- "@vuepress/plugin-theme-data": "~2.0.0-rc.30",
45
+ "@vuepress/helper": "~2.0.0-rc.31",
46
+ "@vuepress/plugin-active-header-links": "~2.0.0-rc.31",
47
+ "@vuepress/plugin-back-to-top": "~2.0.0-rc.31",
48
+ "@vuepress/plugin-copy-code": "~2.0.0-rc.31",
49
+ "@vuepress/plugin-git": "~2.0.0-rc.31",
50
+ "@vuepress/plugin-links-check": "~2.0.0-rc.31",
51
+ "@vuepress/plugin-markdown-container": "~2.0.0-rc.31",
52
+ "@vuepress/plugin-medium-zoom": "~2.0.0-rc.31",
53
+ "@vuepress/plugin-nprogress": "~2.0.0-rc.31",
54
+ "@vuepress/plugin-palette": "~2.0.0-rc.31",
55
+ "@vuepress/plugin-prismjs": "~2.0.0-rc.32",
56
+ "@vuepress/plugin-seo": "~2.0.0-rc.31",
57
+ "@vuepress/plugin-sitemap": "~2.0.0-rc.31",
58
+ "@vuepress/plugin-theme-data": "~2.0.0-rc.31",
59
59
  "@vueuse/core": "^10.9.0",
60
- "sass": "^1.77.1",
60
+ "sass": "^1.77.2",
61
61
  "vue": "^3.4.27"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "sass-loader": "^14.0.0",
65
- "vuepress": "2.0.0-rc.11"
65
+ "vuepress": "2.0.0-rc.12"
66
66
  },
67
67
  "peerDependenciesMeta": {
68
68
  "sass-loader": {
@@ -72,5 +72,5 @@
72
72
  "publishConfig": {
73
73
  "access": "public"
74
74
  },
75
- "gitHead": "e84a9e154e119525784f6934f06a795029798f8f"
75
+ "gitHead": "ae404292432a5ecdc0aa2d1553a7c24273a8c4c3"
76
76
  }