@tachui/modifiers
Version:
Essential styling modifiers for tachUI framework
136 lines (135 loc) • 4.02 kB
JavaScript
var r = Object.defineProperty;
var f = (t, i, e) => i in t ? r(t, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[i] = e;
var o = (t, i, e) => f(t, typeof i != "symbol" ? i + "" : i, e);
import { B as s } from "./base-CkGf4b9G.js";
class a extends s {
constructor() {
super(...arguments);
o(this, "type", "typography");
o(this, "priority", 30);
}
apply(e, n) {
if (!n.element) return;
const l = this.computeTypographyStyles(this.properties);
this.applyStyles(n.element, l);
}
computeTypographyStyles(e) {
const n = {};
return e.size !== void 0 && (n.fontSize = this.toCSSValue(e.size)), e.weight !== void 0 && (n.fontWeight = String(e.weight)), e.family !== void 0 && (typeof e.family == "object" && e.family !== null && "resolve" in e.family ? n.fontFamily = e.family.resolve() : n.fontFamily = e.family), e.lineHeight !== void 0 && (n.lineHeight = typeof e.lineHeight == "number" ? e.lineHeight.toString() : e.lineHeight), e.letterSpacing !== void 0 && (n.letterSpacing = this.toCSSValue(e.letterSpacing)), e.wordSpacing !== void 0 && (n.wordSpacing = this.toCSSValue(e.wordSpacing)), e.align !== void 0 && (n.textAlign = e.align), e.transform !== void 0 && (n.textTransform = `${e.transform} !important`), e.decoration !== void 0 && (n.textDecoration = `${e.decoration} !important`), e.variant !== void 0 && (n.fontVariant = e.variant), e.style !== void 0 && (n.fontStyle = e.style), e.color !== void 0 && (typeof e.color == "object" && e.color !== null && "resolve" in e.color ? n.color = e.color.resolve() : n.color = e.color), e.textOverflow !== void 0 && (n.textOverflow = e.textOverflow), e.whiteSpace !== void 0 && (n.whiteSpace = e.whiteSpace), e.overflow !== void 0 && (n.overflow = e.overflow), n;
}
toCSSValue(e) {
return typeof e == "number" ? `${e}px` : e;
}
}
function y(t) {
return new a(t);
}
function h(t) {
return new a({ align: t });
}
function c(t) {
return new a({ transform: t });
}
function d(t) {
return new a({ decoration: t });
}
function m(t) {
return new a({ size: t });
}
function S(t) {
return new a({ weight: t });
}
function v(t) {
return new a({ lineHeight: t });
}
function z(t) {
return new a({ letterSpacing: t });
}
function x(t) {
return new a({ textOverflow: t });
}
function b(t) {
return new a({ whiteSpace: t });
}
function H(t) {
return new a({ overflow: t });
}
function T(t) {
return c(t);
}
function C(t) {
return new a({ family: t });
}
function F(t) {
return typeof t == "string" ? u(t) : new a({
family: t.family,
size: t.size,
weight: t.weight,
style: t.style
});
}
function u(t) {
const i = {
".largeTitle": { size: 34, weight: 400 },
".title": { size: 28, weight: 400 },
".title2": { size: 22, weight: 400 },
".title3": { size: 20, weight: 400 },
".headline": { size: 17, weight: 600 },
".subheadline": { size: 15, weight: 400 },
".body": { size: 17, weight: 400 },
".callout": { size: 16, weight: 400 },
".footnote": { size: 13, weight: 400 },
".caption": { size: 12, weight: 400 },
".caption2": { size: 11, weight: 400 }
}, e = i[t];
return e ? new a(e) : new a(i[".body"]);
}
function O(t) {
let i;
switch (t.design) {
case "serif":
i = "ui-serif, Georgia, serif";
break;
case "rounded":
i = "ui-rounded, system-ui, -apple-system, sans-serif";
break;
case "monospaced":
i = "ui-monospace, SFMono-Regular, Consolas, monospace";
break;
default:
i = "system-ui, -apple-system, BlinkMacSystemFont, sans-serif";
}
return new a({
family: i,
size: t.size,
weight: t.weight
});
}
function k(t, i) {
return new a({
family: t,
size: i?.size,
weight: i?.weight,
style: i?.style
});
}
export {
a as T,
h as a,
c as b,
d as c,
S as d,
z as e,
m as f,
x as g,
T as h,
C as i,
F as j,
k,
v as l,
H as o,
O as s,
y as t,
b as w
};
//# sourceMappingURL=font-3qM2Z97N.js.map