UNPKG

@catppuccin/daisyui

Version:

🌼 Soothing pastel theme for daisyui

84 lines (77 loc) • 2.42 kB
'use strict'; const daisyThemePlugin = require('daisyui/theme'); const plugin = require('tailwindcss/plugin'); const palette = require('@catppuccin/palette'); function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; } const daisyThemePlugin__default = /*#__PURE__*/_interopDefaultCompat(daisyThemePlugin); const plugin__default = /*#__PURE__*/_interopDefaultCompat(plugin); const defaultThemeOption = { "primary": "lavender", "primary-content": "mantle", "secondary": "surface0", "secondary-content": "text", "accent": "rosewater", "accent-content": "mantle", "neutral": "overlay1", "neutral-content": "mantle", "success": "green", "success-content": "base", "warning": "yellow", "warning-content": "base", "error": "red", "error-content": "base", "info": "sky", "info-content": "mantle", "base-100": "base", "base-200": "mantle", "base-300": "crust", "base-content": "text", "--radius-selector": "0.25rem", "--radius-field": "0.5rem", "--radius-box": "0.5rem", "--size-field": "0.25rem", "--size-selector": "0.25rem", "--border": "1px", "--depth": true, "--noise": false }; function generateTheme(themeName, themeOptions = {}) { const options = { ...defaultThemeOption, ...themeOptions }; const entries = Object.entries(options); const theme = { "color-scheme": palette.flavors[themeName].dark ? "dark" : "light", ...Object.fromEntries(entries.filter(([k]) => k.startsWith("--"))), ...entries.filter(([_, v]) => typeof v === "boolean").reduce((acc, [key, value]) => { acc[key] = value ? "1" : "0"; return acc; }, {}), ...entries.filter(([k]) => !k.startsWith("--")).reduce((acc, [key, value]) => { acc[`--color-${key}`] = palette.flavors[themeName].colors[value].hex; return acc; }, {}) }; return theme; } function createCatppuccinPlugin(themeName, options, daisyOptions = {}) { let theme; if (typeof options === "string") { theme = generateTheme(themeName, { accent: options }); } else { theme = generateTheme(themeName, options); } return plugin__default.withOptions(() => { return (PluginAPI) => { daisyThemePlugin__default({ name: themeName, ...daisyOptions, ...theme }).handler(PluginAPI); }; }); } exports.createCatppuccinPlugin = createCatppuccinPlugin;