mirror of
https://github.com/linkwarden/linkwarden.git
synced 2026-06-28 06:45:50 +00:00
24 lines
570 B
TypeScript
24 lines
570 B
TypeScript
import { vars } from "nativewind";
|
|
import { rawTheme, ThemeName } from "./colors";
|
|
|
|
const hexToRgb = (hex: string) => {
|
|
const [r, g, b] = hex
|
|
.replace(/^#/, "")
|
|
.match(/.{2}/g)!
|
|
.map((h) => parseInt(h, 16));
|
|
return `${r} ${g} ${b}`;
|
|
};
|
|
|
|
const makeVars = (scheme: ThemeName) =>
|
|
vars(
|
|
Object.fromEntries(
|
|
Object.entries(rawTheme[scheme]).map(([key, hex]) => [
|
|
`--color-${key}`,
|
|
hexToRgb(hex),
|
|
])
|
|
) as Record<string, string>
|
|
);
|
|
|
|
export const lightTheme = makeVars("light");
|
|
export const darkTheme = makeVars("dark");
|