pl-fe: make themes work with style-src: self csp
Signed-off-by: Nicole Mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -46,10 +46,10 @@ const PlFeHead = () => {
|
||||
'dark': theme === 'dark',
|
||||
'dark black': theme === 'black',
|
||||
})}
|
||||
// @ts-ignore
|
||||
style={themeCss + ['dark', 'black'].includes(theme) ? 'color-scheme: dark;' : ''}
|
||||
/>
|
||||
<body className={bodyClass} dir={direction} />
|
||||
{themeCss && <style id='theme' type='text/css'>{`:root{${themeCss}}`}</style>}
|
||||
{['dark', 'black'].includes(theme) && <style type='text/css'>{':root { color-scheme: dark; }'}</style>}
|
||||
<meta name='theme-color' content={plFeConfig.brandColor} />
|
||||
</Helmet>
|
||||
);
|
||||
|
||||
@ -76,7 +76,7 @@ const generateNeutral = (brandColor: string): string | null => {
|
||||
return hslToHex({ h, s: 20, l: 55 });
|
||||
};
|
||||
|
||||
const parseShades = (obj: Record<string, any>, color: string, shades: Record<string, any>): void => {
|
||||
const parseShades = (obj: Record<string, string>, color: string, shades: Record<string, any>): void => {
|
||||
if (!shades) return;
|
||||
|
||||
if (typeof shades === 'string') {
|
||||
@ -98,7 +98,7 @@ const parseShades = (obj: Record<string, any>, color: string, shades: Record<str
|
||||
};
|
||||
|
||||
// Convert colors as CSS variables
|
||||
const parseColors = (colors: TailwindColorPalette): TailwindColorPalette =>
|
||||
const parseColors = (colors: TailwindColorPalette): Record<string, string> =>
|
||||
Object.keys(colors).reduce((obj, color) => {
|
||||
parseShades(obj, color, colors[color] as TailwindColorObject);
|
||||
return obj;
|
||||
|
||||
Reference in New Issue
Block a user