@park-ui/panda-preset
Version:
Panda CSS Preset for Park UI
127 lines (123 loc) • 4.07 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/utils/index.ts
var utils_exports = {};
__export(utils_exports, {
createRadii: () => createRadii,
createVariables: () => createVariables
});
module.exports = __toCommonJS(utils_exports);
// src/utils/create-radii.ts
var import_effect = require("effect");
var createRadii = (radii) => import_effect.Match.value(radii).pipe(
import_effect.Match.when("xs", () => ({
l1: { value: "{radii.2xs}" },
l2: { value: "{radii.xs}" },
l3: { value: "{radii.sm}" }
})),
import_effect.Match.when("sm", () => ({
l1: { value: "{radii.xs}" },
l2: { value: "{radii.sm}" },
l3: { value: "{radii.md}" }
})),
import_effect.Match.when("md", () => ({
l1: { value: "{radii.sm}" },
l2: { value: "{radii.md}" },
l3: { value: "{radii.lg}" }
})),
import_effect.Match.when("lg", () => ({
l1: { value: "{radii.md}" },
l2: { value: "{radii.lg}" },
l3: { value: "{radii.xl}" }
})),
import_effect.Match.when("xl", () => ({
l1: { value: "{radii.lg}" },
l2: { value: "{radii.xl}" },
l3: { value: "{radii.2xl}" }
})),
import_effect.Match.when("2xl", () => ({
l1: { value: "{radii.xl}" },
l2: { value: "{radii.2xl}" },
l3: { value: "{radii.3xl}" }
})),
import_effect.Match.orElse(() => ({
l1: { value: "{radii.none}" },
l2: { value: "{radii.none}" },
l3: { value: "{radii.none}" }
}))
);
// src/utils/create-variables.ts
var createVariables = (color) => {
const tokens = createTokens(color);
const semanticTokens = createSemanticTokens(color);
const baseVariables = `
:where(:root, :host) {
${tokens.join("\n ")}
--colors-color-palette-default: var(--colors-${color.name}-default);
--colors-color-palette-emphasized: var(--colors-${color.name}-emphasized);
--colors-color-palette-fg: var(--colors-${color.name}-fg);
--colors-color-palette-text: var(--colors-${color.name}-text);
}
`;
const lightTheme = `
:where(:root, .light) {
${// @ts-expect-error
semanticTokens.light.join("\n ")}
}
`;
const darkTheme = `
.dark {
${// @ts-expect-error
semanticTokens.dark.join("\n ")}
}
`;
return `@layer tokens {${baseVariables}${lightTheme}${darkTheme}
}`;
};
var createTokens = (color) => {
const { name, tokens } = color;
return Object.entries(tokens ?? {}).flatMap(
([condition, value]) => Object.entries(value).map(([key, { value: value2 }]) => {
return `--colors-${name}-${condition}-${key}: ${value2};`;
})
);
};
var createSemanticTokens = (color) => {
const { name, semanticTokens } = color;
const tokensByCondition = {};
Object.entries(semanticTokens ?? {}).forEach(([shade, { value }]) => {
Object.entries(value).forEach(([key, value2]) => {
const condition = key.replace("_", "");
if (!tokensByCondition[condition]) {
tokensByCondition[condition] = [];
}
tokensByCondition[condition].push(`--colors-${name}-${shade}: ${convert(value2)};`);
});
});
return tokensByCondition;
};
var convert = (value) => {
return value.replaceAll(".", "-").replace("{", "var(--").replace("}", ")");
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
createRadii,
createVariables
});
//# sourceMappingURL=index.cjs.map