Skip to content

Commit 0316f46

Browse files
committed
feat(ColorMode): using defaultConfig to colorMode
1 parent 02efaa9 commit 0316f46

File tree

6 files changed

+34
-15
lines changed

6 files changed

+34
-15
lines changed

Diff for: config/defaultThemeConfig.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const colorMode = {
2+
enabled: true,
3+
visible: true,
4+
props: {
5+
modes: ['light', 'dark', 'system', 'sepia']
6+
}
7+
}

Diff for: docs/.vuepress/config.js

-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ module.exports = {
1010
docsDir: 'docs',
1111
docsBranch: 'master',
1212
editLinks: true,
13-
colorMode: {
14-
props: {
15-
modes: [ 'light', 'dark', 'system', 'sepia' ]
16-
}
17-
},
1813
locales: {
1914
'/': {
2015
editLinkText: 'Edit this page on GitHub',

Diff for: docs/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ It does not replace the default vuepress theme, however, this theme contains mos
66

77
## Packages included
88

9-
- [vue-skip-to](https://github.com/vue-a11y/vue-skip-to)
109
- [vue-axe](https://github.com/vue-a11y/vue-axe)
10+
- [vue-skip-to](https://github.com/vue-a11y/vue-skip-to)
1111
- [@vue-a11y/dark-mode](https://github.com/vue-a11y/vue-dark-mode)
1212
- [@vue-a11y/announcer](https://github.com/vue-a11y/vue-announcer)

Diff for: mixins/colorMode.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1+
import merge from 'deepmerge'
2+
import { colorMode } from '../config/defaultThemeConfig'
3+
14
export default {
25
computed: {
36
configColorMode () {
4-
if (!this.$themeConfig.colorMode || !Object.keys(this.$themeConfig.colorMode).length) return {}
5-
return this.$themeConfig.colorMode
7+
if (!this.$themeConfig.colorMode || !Object.keys(this.$themeConfig.colorMode).length) return colorMode
8+
return merge(colorMode, this.$themeConfig.colorMode)
69
},
710

811
isColorModeEnabled () {
9-
return typeof this.configColorMode.enabled === 'undefined' ? true : this.configColorMode.enabled
12+
return this.configColorMode.enabled
1013
},
1114

1215
isColorModeVisible () {
13-
return typeof this.configColorMode.visible === 'undefined' ? true : this.configColorMode.visible
16+
return this.configColorMode.visible
1417
},
1518

1619
getColorModeProps () {
17-
const props = this.configColorMode.props || {}
18-
return { ...props, ...this.getColorModeAriaByLocale }
20+
return { ...this.configColorMode.props, ...this.getColorModeAriaByLocale }
1921
},
2022

2123
getColorModeAriaByLocale () {

Diff for: package-lock.json

+17-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"devDependencies": {
3333
"@vue/eslint-config-standard": "^5.1.2",
3434
"babel-eslint": "^10.1.0",
35+
"deepmerge": "^4.2.2",
3536
"eslint": "^6.8.0",
3637
"eslint-plugin-import": "^2.20.2",
3738
"eslint-plugin-node": "^11.1.0",

0 commit comments

Comments
 (0)