mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 20:38:52 +00:00
feat: init @toeverything/theme (#2136)
This commit is contained in:
@@ -1,19 +1,6 @@
|
||||
import type { AffineCssVariables } from '@affine/component';
|
||||
import { darkCssVariables, lightCssVariables } from '@toeverything/theme';
|
||||
import { globalStyle } from '@vanilla-extract/css';
|
||||
|
||||
import { darkTheme, lightTheme } from '../styles/theme';
|
||||
|
||||
const camelToKebab = (s: string) => {
|
||||
if (typeof s !== 'string') return '';
|
||||
return s
|
||||
.replace(/-/g, '_')
|
||||
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
||||
.replace(/([A-Z])([A-Z])(?=[a-z])/g, '$1-$2')
|
||||
.toLowerCase()
|
||||
.replace(/(\D+)(\d+)$/g, '$1-$2')
|
||||
.replace(/\s|_/g, '-');
|
||||
};
|
||||
|
||||
globalStyle('body', {
|
||||
color: 'var(--affine-text-primary-color)',
|
||||
fontFamily: 'var(--affine-font-family)',
|
||||
@@ -22,21 +9,9 @@ globalStyle('body', {
|
||||
});
|
||||
|
||||
globalStyle('html', {
|
||||
vars: {
|
||||
...Object.entries(lightTheme).reduce((variables, [key, value]) => {
|
||||
variables[`--affine-${camelToKebab(key)}` as keyof AffineCssVariables] =
|
||||
value;
|
||||
return variables;
|
||||
}, {} as AffineCssVariables),
|
||||
},
|
||||
vars: lightCssVariables,
|
||||
});
|
||||
|
||||
globalStyle('html[data-theme="dark"]', {
|
||||
vars: {
|
||||
...Object.entries(darkTheme).reduce((variables, [key, value]) => {
|
||||
variables[`--affine-${camelToKebab(key)}` as keyof AffineCssVariables] =
|
||||
value;
|
||||
return variables;
|
||||
}, {} as AffineCssVariables),
|
||||
},
|
||||
vars: darkCssVariables,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user