@veracity/vui
Version:
Veracity UI is a React component library crafted for use within Veracity applications and pages. Based on Styled Components and @xstyled.
24 lines (23 loc) • 1.02 kB
JavaScript
//#region src/tag/utils.ts
/** Canonical hierarchy keys recognised by the two-prop API. */
const HIERARCHY_KEYS = /* @__PURE__ */ new Set(["subtle", "solid"]);
const capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
/**
* Converts a two-prop variant+color pair into the combined theme key used
* internally (e.g. `resolveTagVariantKey('subtle','blue') => 'subtleBlue'`).
* When `color` is omitted, `'blue'` is used as the default.
*
* If `variant` is already a fully-qualified legacy key (e.g. `'subtleBlue'` or
* `'subtleBlue'`) it is returned unchanged so the new API is backward-compatible.
*
* Returns `'subtleBlue'` (the default variant) when `variant` is absent.
*/
const resolveTagVariantKey = (variant, color) => {
if (!variant) return `subtle${capitalize(color ?? "blue")}`;
if (!HIERARCHY_KEYS.has(variant)) return variant;
return `${variant}${capitalize(color ?? "blue")}`;
};
//#endregion
export { resolveTagVariantKey };
globalThis.__vuiVersion__ = "5.3.1"
//# sourceMappingURL=utils.js.map