@hakit/components
Version:
A series of components to work with @hakit/core
44 lines (43 loc) • 1.27 kB
JavaScript
const p = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], l = ["xxs", "xs", "sm", "md", "lg"], d = [...l, "xlg"], $ = (n) => {
const t = l.filter((e) => n[e] !== void 0).map((e) => [e, n[e]]), r = {};
for (let e = 0; e < t.length; e++) {
const [o, s] = t[e];
if (e > 0) {
const a = t[e - 1][1];
if (s <= a)
throw new Error(`Breakpoint "${o}" must be greater than "${t[e - 1][0]}". Got ${s} <= ${a}.`);
r[o] = `(min-width: ${a + 1}px) and (max-width: ${s}px)`;
} else
r[o] = `(max-width: ${s}px)`;
}
const i = t.length === 0 ? -1 : t[t.length - 1][1];
return r.xlg = `(min-width: ${i + 1}px)`, r;
}, c = (n, t) => n.map((r) => `
.bp-${r} & {
${t}
}
`).join(`
`), u = (n) => `calc(
(100% - 11 * var(--gap, 0px)) * ${n} / 12 + (${n} - 1) * var(--gap, 0px)
)`, x = (n) => Object.entries(n).reduce((t, [r, i]) => {
if (i === void 0)
return t;
const e = p.map((o) => `
.bp-${r} {
.${r}-${o} {
width: ${u(o)};
}
}
`);
return t + e.join(`
`);
}, "");
export {
d as allBreakpoints,
x as generateColumnBreakpoints,
$ as getBreakpoints,
u as getColumnSizeCSS,
c as mq,
l as orderedBreakpoints
};
//# sourceMappingURL=breakpoints.js.map