mirror of
https://github.com/linkwarden/linkwarden.git
synced 2026-06-30 07:46:13 +00:00
15 lines
444 B
TypeScript
15 lines
444 B
TypeScript
import Color from "colorjs.io";
|
|
|
|
const oklchVariableToHex = (variable: string): string => {
|
|
const rootStyle = getComputedStyle(document.documentElement);
|
|
const rawColor = rootStyle.getPropertyValue(variable).trim();
|
|
const oklchColor = `oklch(${rawColor})`;
|
|
const hexColor = new Color(oklchColor)
|
|
.toGamut({ space: "srgb" })
|
|
.to("srgb")
|
|
.toString({ format: "hex" });
|
|
return hexColor;
|
|
};
|
|
|
|
export default oklchVariableToHex;
|