feat: init @toeverything/theme (#2136)

This commit is contained in:
Himself65
2023-04-25 18:44:17 -05:00
committed by GitHub
parent 80f4578f76
commit db52c63d25
34 changed files with 147 additions and 76 deletions

View File

@@ -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,
});