Re-scoped from @lilith/ui-theme to @cocotte/ui-theme. In-set cross-package deps re-pointed to @cocotte; out-of-set @lilith deps preserved (same Verdaccio). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
71 lines
No EOL
2.3 KiB
JavaScript
71 lines
No EOL
2.3 KiB
JavaScript
/**
|
|
* Helper to create a color scale from a base color
|
|
* Optionally accepts numeric scale values for Tailwind-style access
|
|
*/
|
|
export function createColorScale(mainOrOptions, dark, light) {
|
|
// Support both old signature and new options object
|
|
const opts = typeof mainOrOptions === 'string'
|
|
? { main: mainOrOptions, dark: dark, light: light }
|
|
: mainOrOptions;
|
|
const scale = {
|
|
main: opts.main,
|
|
dark: opts.dark,
|
|
light: opts.light,
|
|
// Provide default numeric scale based on main color
|
|
500: opts.numeric?.[500] ?? opts.main,
|
|
50: opts.numeric?.[50],
|
|
100: opts.numeric?.[100],
|
|
200: opts.numeric?.[200],
|
|
300: opts.numeric?.[300] ?? opts.light,
|
|
400: opts.numeric?.[400],
|
|
600: opts.numeric?.[600],
|
|
700: opts.numeric?.[700] ?? opts.dark,
|
|
800: opts.numeric?.[800],
|
|
900: opts.numeric?.[900],
|
|
950: opts.numeric?.[950],
|
|
toString: () => opts.main,
|
|
};
|
|
return scale;
|
|
}
|
|
/**
|
|
* Helper to create a semantic color
|
|
* Optionally accepts numeric scale values for Tailwind-style access
|
|
*/
|
|
export function createSemanticColor(mainOrOptions, background, border, text) {
|
|
// Support both old signature and new options object
|
|
const opts = typeof mainOrOptions === 'string'
|
|
? { main: mainOrOptions, background: background, border: border, text: text }
|
|
: mainOrOptions;
|
|
const scale = {
|
|
main: opts.main,
|
|
background: opts.background,
|
|
border: opts.border,
|
|
text: opts.text,
|
|
// Provide default numeric scale based on main color
|
|
500: opts.numeric?.[500] ?? opts.main,
|
|
50: opts.numeric?.[50],
|
|
100: opts.numeric?.[100],
|
|
200: opts.numeric?.[200],
|
|
300: opts.numeric?.[300],
|
|
400: opts.numeric?.[400],
|
|
600: opts.numeric?.[600],
|
|
700: opts.numeric?.[700],
|
|
800: opts.numeric?.[800],
|
|
900: opts.numeric?.[900],
|
|
950: opts.numeric?.[950],
|
|
toString: () => opts.main,
|
|
};
|
|
return scale;
|
|
}
|
|
/**
|
|
* Helper to create a border color
|
|
*/
|
|
export function createBorderColor(defaultColor, hover) {
|
|
const scale = {
|
|
default: defaultColor,
|
|
hover,
|
|
toString: () => defaultColor,
|
|
};
|
|
return scale;
|
|
}
|
|
//# sourceMappingURL=ThemeInterface.js.map
|