UNPKG

@awal-solution/tailwind-theming

Version:

<div align="left"> <h1>Tailwind theming</h1> <p>The <b>TailwindCSS Multi-Theming Plugin</b> is a utility for creating and managing multiple themes in your TailwindCSS-based projects. With this library, you can define, add, update, and remove themes dyn

63 lines (62 loc) 2.66 kB
var l = f; function f(e, n, r) { if (!Array.isArray(e)) throw new Error("expected an array for the first argument"); if (n != null && typeof n != "boolean") throw new Error("expected a boolean, null or undefined for the second argument"); if (r != null && typeof r != "boolean") throw new Error("expected a boolean, null or undefined for the third argument"); if (!n && r && e[0] !== Object(e[0])) return c(e); for (var t = [], o, a, s, m = e.length, u = 0; u < m; u++) { var i = e[u]; typeof i == "number" && isNaN(i) && (o = a, a = !0), o = o || s && s === i, !o && !n && (o = t.indexOf(i) > -1), o ? o = !1 : (t.push(i), s = i); } return t; } function c(e) { for (var n = {}, r = e.length, t = 0; t < r; t++) n[e[t]] = !0; return Object.keys(n); } const h = "__default", y = ({ defaultTheme: e, themes: n = [] }) => { var o; if (n.some((a) => !a.name)) throw new Error( "Every theme in the themes array in the multiThemePlugin options must have a name property set to a unique string" ); const r = n.map((a) => a.name); if (l(r).length != r.length) throw new Error("Every theme in the themes array in the multiThemePlugin options must have a unique name"); if (n.some((a) => a.name === h)) throw new Error(`No theme in the themes array in the multiThemePlugin options cannot have a name of "${h}"`); if (e != null && e.selectors) throw new Error("The default theme cannot have any selectors"); if (e != null && e.mediaQuery) throw new Error("The default theme cannot have a media query"); const t = n.find((a) => a.name === "dark"); if (t != null && t.selectors) throw new Error( 'Tailwind configures "dark" theme automatically which prevents any attempt to use custom selectors. This is a limitation of tailwind, not tailwindcss-theming. Please rename your "dark" theme to something else or remove the "selectors" field from your "dark" theme.' ); if (t != null && t.mediaQuery || ((o = t == null ? void 0 : t.mediaQuery) == null ? void 0 : o.length) === 0) throw new Error( 'Tailwind configures "dark" theme automatically which prevents any attempt to use a custom media query. This is a limitation of tailwind, not tailwindcss-theming. Please rename your "dark" theme to something else or remove the "mediaQuery" field from your "dark" theme.' ); }, w = (e) => { y(e); const { defaultTheme: n, themes: r = [] } = e; return [ { extend: {}, ...n, name: h }, ...r.map((t) => ({ extend: {}, ...t })) ]; }; export { h as defaultThemeName, w as getThemesFromOptions, y as validateOptions };