doc: add colorScheme

feat-css-var
tangjinzhou 2022-03-10 17:07:06 +08:00
parent d783c4e913
commit 414338bafd
4 changed files with 6 additions and 2 deletions

View File

@ -2,6 +2,6 @@
// This will be replaced in webpack bundle
// @root-entry-name: variable;
@import './default.less';
// @import './default.less';
// @import './variable.less';
// @import './@{root-entry-name}.less';
@import './@{root-entry-name}.less';

View File

@ -89,9 +89,11 @@ export default defineComponent({
if (theme.value === 'dark') {
document.getElementsByTagName('html')[0].setAttribute('data-doc-theme', 'dark');
document.getElementsByTagName('body')[0].setAttribute('data-theme', 'dark');
document.getElementsByTagName('html')[0].style.colorScheme = 'dark';
} else {
document.getElementsByTagName('html')[0].setAttribute('data-doc-theme', 'light');
document.getElementsByTagName('body')[0].setAttribute('data-theme', 'light');
document.getElementsByTagName('html')[0].style.colorScheme = 'light';
}
},
{ immediate: true },

View File

@ -13,6 +13,7 @@ const themeConfig = [
'gray-8': '@text-color',
'background-color-base': '#555',
'skeleton-color': 'rgba(0,0,0,0.8)',
'root-entry-name': 'dark',
},
},
];

View File

@ -49,6 +49,7 @@ export default {
modifyVars: {
hack: `true;@import "${require.resolve('../components/style/color/colorPalette.less')}";`,
...defaultVar,
'root-entry-name': 'variable',
},
javascriptEnabled: true,
// includePaths: ["node_modules/"],