fui-fancyui
Version:
FancyUI Libary
36 lines (35 loc) • 1.17 kB
JavaScript
import s from "../getThemeOrValueAsCss/getThemeOrValueAsCss.js";
const l = (t, i) => {
if (!t || typeof t != "object" && !t.toString().length || Object.keys(t).length === 0)
return "";
let e = [];
if (typeof t == "string" || typeof t == "number")
e.push(t);
else if (typeof t == "object" && Array.isArray(t) === !1) {
const { t: r = 0, r: o = 0, b: n = 0, l: f = 0 } = t;
e = [r, o, n, f].filter((c) => c !== void 0);
} else Array.isArray(t) && (e = t.filter((r) => r !== void 0));
switch (e.length) {
// if one value is given, all edges are the same
case 1:
return ` ${s(e[0], i)} `;
// if two values are given, top/bottom and left/right are the same
case 2: {
const [r, o] = e.map((n) => s(n, i));
return ` ${r} ${o} `;
}
// if three values are given, top, left/right and bottom are the same
case 3: {
const [r, o, n] = e.map((f) => s(f, i));
return ` ${r} ${o} ${n} ${o} `;
}
// if four values are given, all edges are different
case 4: {
const [r, o, n, f] = e.map((c) => s(c, i));
return ` ${r} ${o} ${n} ${f} `;
}
}
};
export {
l as default
};