@catppuccin/daisyui
Version:
🌼 Soothing pastel theme for daisyui
49 lines (46 loc) • 1.46 kB
JavaScript
import { flavorEntries } from '@catppuccin/palette';
const defaultColorOptions = {
primary: "lavender",
secondary: "surface0",
accent: "rosewater",
neutral: "overlay1",
success: "green",
warning: "yellow",
error: "red",
info: "sky"
};
function getSemanticColors(options = {}) {
return { ...defaultColorOptions, ...options };
}
function createFlavor(theme, options) {
const palette = flavorEntries.find(([name]) => name === theme)?.[1];
if (!palette)
throw new Error(`Flavor ${theme} not found!`);
let customColors;
if (typeof options === "string") {
customColors = getSemanticColors({
accent: options
});
} else {
customColors = getSemanticColors(options);
}
const { primary, secondary, accent, neutral, info, success, error, warning } = customColors;
const daisyTheme = {
[theme]: {
"color-scheme": palette.dark ? "dark" : "light",
"base-100": palette.colors.base.hex,
"base-200": palette.colors.mantle.hex,
"base-300": palette.colors.crust.hex,
"primary": palette.colors[primary].hex,
"secondary": palette.colors[secondary].hex,
"accent": palette.colors[accent].hex,
"neutral": palette.colors[neutral].hex,
"success": palette.colors[success].hex,
"warning": palette.colors[warning].hex,
"error": palette.colors[error].hex,
"info": palette.colors[info].hex
}
};
return daisyTheme;
}
export { createFlavor as default };