index.ts
531 Bytes
import { getThemeColors, ThemeMode, generateColors } from '../../../build/config/themeConfig';
import { replaceStyleVariables } from 'vite-plugin-theme/es/client';
import { mixLighten, mixDarken, tinycolor } from 'vite-plugin-theme/es/colorUtils';
export async function changeTheme(color: string, theme?: ThemeMode) {
const colors = generateColors({
mixDarken,
mixLighten,
tinycolor,
color,
});
return await replaceStyleVariables({
colorVariables: [...getThemeColors(color, theme), ...colors],
});
}