Commit 0591b55d by xinla

hsl css var

1 parent 66f3b251
:root { :root {
--hsl: 149, 93%, 39%; /* 主题色hsl*/ /* 主题色hsl*/
--hsl-dark: 149, 93%, 34%; /* 深主题色hsl*/ --h: 149;
--s: 93%;
--l: 39%;
--l-dark: calc(var(--l) - 5%); /* 深主题色 l */
--hsl: var(--h), var(--s), var(--l); /* 主题色hsl*/
--hsl-dark: var(--h), var(--s), var(--l-dark); /* 深主题色hsl*/
--color: hsl(var(--hsl)); /* 主题色 hsl(149, 93%, 39%)*/ --color: hsl(var(--hsl)); /* 主题色 hsl(149, 93%, 39%)*/
--color-dark: hsl(var(--hsl-dark)); /* 深主题色 */ --color-dark: hsl(var(--hsl-dark)); /* 深主题色 hsl(149, 93%, 34%) */
--color-light: hsl(var(--hsl), 0.12); /* 浅主题色 */
--color-sub: hsl(91, 70%, 57%); /* 主题辅色 */ --color-sub: hsl(91, 70%, 57%); /* 主题辅色 */
/* 浅主题色 递浅系列阶梯 */
--color-light: hsl(var(--hsl), 0.12);
--color-light-3: hsl(var(--hsl), 0.7);
--color-light-5: hsl(var(--hsl), 0.5);
--color-light-7: hsl(var(--hsl), 0.3);
--color-light-8: hsl(var(--hsl), 0.2);
--color-light-9: hsl(var(--hsl), 0.1);
/* 功能色 */
--color-success: #07c160; --color-success: #07c160;
--color-warning: #faad14; --color-warning: #faad14;
--color-danger: #eb5e12; --color-danger: #eb5e12;
...@@ -18,6 +32,16 @@ ...@@ -18,6 +32,16 @@
--top-nav-heght: 64px; /* 顶部导航条高度 */ --top-nav-heght: 64px; /* 顶部导航条高度 */
--font-black: #1d2129; /* 通用字体黑色 */ --font-black: #1d2129; /* 通用字体黑色 */
--black-: #000;
--black-d2: rgba(0, 0, 0, 0.2); /* 黑色 #ddd*/
--black-d3: rgba(0, 0, 0, 0.3); /* 黑色 #ccc*/
--black-d4: rgba(0, 0, 0, 0.4); /* 黑色 #aaa*/
--black-d5: rgba(0, 0, 0, 0.5); /* 黑色 */
--black-d6: rgba(0, 0, 0, 0.6); /* 黑色 */
--black-d7: rgba(0, 0, 0, 0.7); /* 黑色 */
--black-d8: rgba(0, 0, 0, 0.8); /* 黑色 */
--black-d9: rgba(0, 0, 0, 0.9); /* 黑色 */
--font-white: #fff; /* 通用字体白色 */ --font-white: #fff; /* 通用字体白色 */
/* 背景色,暗黑模式下为黑色 */ /* 背景色,暗黑模式下为黑色 */
......
...@@ -81,11 +81,15 @@ window.lwConfig = Object.assign(config, env, common, lwConfig, project) ...@@ -81,11 +81,15 @@ window.lwConfig = Object.assign(config, env, common, lwConfig, project)
// 主题回显 // 主题回显
const [h, s, l] = localStorage.hsl?.split(',')?.map((e) => e.trim()) || [] const [h, s, l] = localStorage.hsl?.split(',')?.map((e) => e.trim()) || []
const l1 = l?.slice(0, -1) - 5 // const l1 = l?.slice(0, -1) - 5
if (h) { if (h) {
const style = document.documentElement.style const style = document.documentElement.style
style.setProperty('--hsl', localStorage.hsl) style.setProperty('--h', h)
style.setProperty('--hsl-dark', `${h},${s},${l1}%`) style.setProperty('--s', s)
style.setProperty('--l', l)
// style.setProperty('--hsl', localStorage.hsl)
// style.setProperty('--hsl-dark', `${h},${s},${l1}%`)
style.setProperty('--color-sub', localStorage.colorSub) style.setProperty('--color-sub', localStorage.colorSub)
} }
......
...@@ -99,10 +99,13 @@ export default { ...@@ -99,10 +99,13 @@ export default {
.slice(4, -1) .slice(4, -1)
.split(',') .split(',')
.map((e) => e.trim()) .map((e) => e.trim())
let l1 = l.slice(0, -1) - 5 // 主题色明暗度减5%即为深主题色 // let l1 = l.slice(0, -1) - 5 // 主题色明暗度减5%即为深主题色
let style = document.documentElement.style let style = document.documentElement.style
style.setProperty('--hsl', `${h},${s},${l}`) style.setProperty('--h', h)
l1 && style.setProperty('--hsl-dark', `${h},${s},${l1}%`) style.setProperty('--s', s)
style.setProperty('--l', l)
// style.setProperty('--hsl', `${h},${s},${l}`)
// l1 && style.setProperty('--hsl-dark', `${h},${s},${l1}%`)
localStorage.hsl = `${h},${s},${l}` localStorage.hsl = `${h},${s},${l}`
} }
...@@ -118,8 +121,11 @@ export default { ...@@ -118,8 +121,11 @@ export default {
// 恢复默认主题 // 恢复默认主题
reset() { reset() {
let style = document.documentElement.style let style = document.documentElement.style
style.removeProperty('--hsl') style.removeProperty('--h')
style.removeProperty('--hsl-dark') style.removeProperty('--s')
style.removeProperty('--l')
// style.removeProperty('--hsl')
// style.removeProperty('--hsl-dark')
style.removeProperty('--color-sub') style.removeProperty('--color-sub')
localStorage.hsl = '' localStorage.hsl = ''
localStorage.colorSub = '' localStorage.colorSub = ''
......
...@@ -4,15 +4,15 @@ ...@@ -4,15 +4,15 @@
/* element-plus var */ /* element-plus var */
:root, :root,
html.dark { html.dark {
--el-color-primary: hsl(var(--hsl)); --el-color-primary: var(--color);
--el-color-primary-light-3: hsl(var(--hsl), 0.7); --el-color-primary-light-3: var(--color-light-3);
--el-color-primary-light-5: hsl(var(--hsl), 0.5); --el-color-primary-light-5: var(--color-light-5);
--el-color-primary-light-7: hsl(var(--hsl), 0.3); --el-color-primary-light-7: var(--color-light-7);
--el-color-primary-light-8: hsl(var(--hsl), 0.2); --el-color-primary-light-8: var(--color-light-8);
--el-color-primary-light-9: hsl(var(--hsl), 0.1); --el-color-primary-light-9: var(--color-light-9);
--el-color-primary-dark-2: var(--color-dark); --el-color-primary-dark-2: var(--color-dark);
--el-color-success: hsl(var(--hsl)); --el-color-success: var(--color-success);
/* // --el-color-info: #fa7216; /* // --el-color-info: #fa7216;
// --el-color-info: #1E1E1E; */ // --el-color-info: #1E1E1E; */
...@@ -25,8 +25,8 @@ html.dark { ...@@ -25,8 +25,8 @@ html.dark {
/* // --el-color-text-regular: #1f2d3d; */ /* // --el-color-text-regular: #1f2d3d; */
} }
:root { :root {
--el-color-warning: #faad14; --el-color-warning: var(--color-warning);
--el-color-danger: #eb5e12; --el-color-danger: var(--color-danger);
--el-border-color-extra-light: #e6f8ef; --el-border-color-extra-light: #e6f8ef;
--el-border-color-light: #dfe4ed; --el-border-color-light: #dfe4ed;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!