Open fangmd opened 9 months ago
document.body.style.setProperty('--primary-color', defaultSkin);
:root {
--color-primary: 0, 0, 255;
--foreground-rgb: 0, 0, 0;
--bg-rgb: 255, 255, 255;
}
.dark {
--color-primary: 255, 0, 0;
--foreground-rgb: 255, 255, 255;
--bg-rgb: 0, 0, 0;
}
body {
color: rgb(var(--foreground-rgb));
background: rgb(var(--bg-rgb));
}
.text-primary {
color: rgb(var(--color-primary));
}
document.documentElement.classList.toggle('dark')
html
class
实现rules: [['text-custom', { color: 'rgb(var(--color-custom))' }]],
--color-custom: 0, 222, 255;
[/^text-(\w+)$/, (match) => ({ color: `rgb(var(--color-${match}))` })],
--color-text-custom2: 255, 222, 255;
Oh, my goodness, this is so amazing
方案一:
color-scheme
不兼容 IE 浏览器