Skip to content

Commit cfc77e3

Browse files
committed
feat(docs): Add how to create a new theme color
1 parent 9d4c803 commit cfc77e3

File tree

5 files changed

+95
-3
lines changed

5 files changed

+95
-3
lines changed

Diff for: docs/.vuepress/config.js

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ module.exports = {
1010
docsDir: 'docs',
1111
docsBranch: 'master',
1212
editLinks: true,
13+
// colorMode: {
14+
// props: {
15+
// modes: [ 'high-contrast']
16+
// }
17+
// },
1318
locales: {
1419
'/': {
1520
editLinkText: 'Edit this page on GitHub',
136 KB
Loading

Diff for: docs/.vuepress/styles/index.styl

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// html.high-contrast-mode
2+
// --bg: $highContrastBg
3+
// --bg-secondary: $highContrastBgSecondary
4+
// --bg-code: $highContrastBgCode
5+
// --bg-search: $highContrastBgSearch
6+
// --bg-code-block: $highContrastBgCodeBlock
7+
// --color: $highContrastColor
8+
// --accent-color: $highContrastAccentColor
9+
// --text-color-link: $highContrastTextColorLink
10+
// --border-color: $highContrastBorderColor
11+
// --text-color-code: $highContrastTextColorCode
12+
// --outline-color: $highContrastOutlineColor
13+
// --bg-tip-danger: $highContrastBgTipDanger
14+
// --bg-tip-warning: $highContrastBgTipWarning
15+
16+
// .custom-block.warning
17+
// color: #000

Diff for: docs/.vuepress/styles/palette.styl

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// $highContrastBg = #000
2+
// $highContrastBgSecondary = lighten($highContrastBg, 8%)
3+
// $highContrastColor = #fff
4+
// $highContrastBgCode = #111
5+
// $highContrastBgSearch = $highContrastBgSecondary
6+
// $highContrastBgCodeBlock = $highContrastBgSecondary
7+
// $highContrastAccentColor = #1bf4a5
8+
// $highContrastTextColorLink = $highContrastAccentColor
9+
// $highContrastBorderColor = $highContrastColor
10+
// $highContrastTextColorCode = #f33bee
11+
// $highContrastOutlineColor = $highContrastColor
12+
// $highContrastBgTipDanger = #AD0000
13+
// $highContrastBgTipWarning = #fdff00

Diff for: docs/guide/styles.md

+60-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Override colors
44

5-
You can easily override the [default palette colors](https://github.com/vue-a11y/vuepress-theme-default-vue-a11y/blob/master/styles/palette.styl) by creating the `.vuepress/styles/palette.style` file.
5+
You can easily override the [default palette colors](https://github.com/vue-a11y/vuepress-theme-default-vue-a11y/blob/master/styles/palette.styl) by creating the `.vuepress/styles/palette.styl` file.
66

77
**e.g.**
88

@@ -20,6 +20,63 @@ The theme comes with light, dark and sepia color palettes.
2020
**If you don't want to make any of these themes available, just don't include them in the `colorMode` property**
2121
:::
2222

23-
## New theme color
23+
## Add theme color
2424

25-
Pretty soon
25+
To create a new theme is simple, first you need to add this new theme in the props of the colorMode property in themeConfig.
26+
27+
```javascript
28+
// e.g. docs/.vuepress/config.js
29+
module.exports = {
30+
themeConfig: {
31+
colorMode: {
32+
props: {
33+
modes: [ 'high-contrast' ]
34+
}
35+
}
36+
}
37+
```
38+
39+
You now need to create the style files where you will create new variables.
40+
41+
```scss
42+
// e.g. docs/.vuepress/styles/palette.styl
43+
$highContrastBg = #000
44+
$highContrastBgSecondary = lighten($highContrastBg, 8%)
45+
$highContrastColor = #fff
46+
$highContrastBgCode = #111
47+
$highContrastBgSearch = $highContrastBgSecondary
48+
$highContrastBgCodeBlock = $highContrastBgSecondary
49+
$highContrastAccentColor = #1bf4a5
50+
$highContrastTextColorLink = $highContrastAccentColor
51+
$highContrastBorderColor = $highContrastColor
52+
$highContrastTextColorCode = #f33bee
53+
$highContrastOutlineColor = $highContrastColor
54+
$highContrastBgTipDanger = #AD0000
55+
$highContrastBgTipWarning = #fdff00
56+
```
57+
58+
```scss
59+
// e.g. docs/.vuepress/styles/index.styl
60+
html.high-contrast-mode
61+
--bg: $highContrastBg
62+
--bg-secondary: $highContrastBgSecondary
63+
--bg-code: $highContrastBgCode
64+
--bg-search: $highContrastBgSearch
65+
--bg-code-block: $highContrastBgCodeBlock
66+
--color: $highContrastColor
67+
--accent-color: $highContrastAccentColor
68+
--text-color-link: $highContrastTextColorLink
69+
--border-color: $highContrastBorderColor
70+
--text-color-code: $highContrastTextColorCode
71+
--outline-color: $highContrastOutlineColor
72+
--bg-tip-danger: $highContrastBgTipDanger
73+
--bg-tip-warning: $highContrastBgTipWarning
74+
```
75+
76+
::: tip
77+
You can consult the existing css variables in the theme through [this link](https://github.com/vue-a11y/vuepress-theme-default-vue-a11y/blob/master/styles/index.styl)
78+
:::
79+
80+
<p align="center">
81+
<img src="/high-contrast-theme-example.png" alt="A preview of the theme in high contrast colors framed on an apple safari dark browser">
82+
</p>

0 commit comments

Comments
 (0)