import StyleDictionary from "style-dictionary"; // only puts LCH values together into a string, does not convert from other color formats StyleDictionary.registerTransform({ name: "value/color/oklch", type: "value", transitive: true, matcher: (token) => token.attributes.category === "color", transformer(token) { if ( !token.value || typeof token.value === "string" || !token.value.hasOwnProperty("l") || !token.value.hasOwnProperty("c") || !token.value.hasOwnProperty("h") ) { return token.value; } const { l, c, h, a, } = token.value; return a ? `oklch(${l}% ${c} ${h} / ${a})` : `oklch(${l}% ${c} ${h})`; }, });