@hakit/components
Version:
A series of components to work with @hakit/core
40 lines (39 loc) • 1 kB
JavaScript
import { create as n } from "zustand";
import { DEFAULT_THEME_OPTIONS as e, DEFAULT_BREAKPOINTS as s } from "./constants.js";
const d = n((i) => ({
theme: {
hue: e.hue,
lightness: e.lightness,
tint: e.tint,
saturation: e.saturation,
darkMode: e.darkMode,
contrastThreshold: e.contrastThreshold
},
setTheme: (t) => {
i((r) => ({
theme: {
...r.theme,
// Only spread properties that are not undefined
...Object.fromEntries(Object.entries(t).filter(([, o]) => o !== void 0))
}
}));
},
breakpoints: s,
setBreakpoints: (t) => {
if (Object.keys(t).length === 0)
throw new Error("No breakpoints provided");
const r = Math.max(...Object.values(t).filter((o) => typeof o == "number"));
if (r === -1 / 0)
throw new Error("No valid breakpoints provided");
i({
breakpoints: {
...t,
xlg: r + 1
}
});
}
}));
export {
d as useThemeStore
};
//# sourceMappingURL=store.js.map