Reconstruye el portal del becario con el lenguaje visual del diseño (paleta crema, tipografías Bricolage Grotesque/Figtree, íconos de línea, logo de la Fundación) sin tocar la lógica ni el cableado al backend. theme.js: - El set "cream" ahora también atiende el flavor 'becario' (móvil, igual que checada). Añade StatusBadge (mapea el estado real al color), HorasCard (barra de avance + variante "¡Meta cumplida!" con estrella), la variante 'success' de Aviso, el Btn 'ghost', los íconos star/calendar y el tono neutral. El camino de panel queda intacto (COLORS/FONT). becario.html: - Migra login/registro y portal a los componentes cream. Los ~14 estados del inventario se conservan y cada uno se dispara por su MISMO code/estado (429, TELEFONO_YA_REGISTRADO, motivo de registro 4xx, pendiente, meta al 100%, jornadas vacío/lista, solicitud enviada…). Endpoints, campos (telefono/password/nombre/entrada_ts), guardia de sesión y el cálculo de horas en el backend sin cambios. - Copy más claro: una jornada sin salida muestra "sin salida" (no "abierta", que chocaba con el badge); el campo de olvido lleva label "Fecha y hora de entrada". Sin marcos de iPhone ni barra de estado. checada.html y panel.html quedan byte-idénticos.
375 lines
21 KiB
JavaScript
375 lines
21 KiB
JavaScript
/*
|
|
* theme.js — base visual compartida de las tres pantallas (panel/becario/checada).
|
|
*
|
|
* Sin build step: se carga como <script src="theme.js"> DESPUÉS de React/ReactDOM
|
|
* y ANTES del <script type="text/babel"> de cada página. Expone window.Theme con:
|
|
* - COLORS paleta unificada (base común de los tres + primaryDark/accentBg del panel)
|
|
* - FONT stack tipográfico del sistema
|
|
* - SPACE escala de espaciado (para el rediseño)
|
|
* - RADIUS escala de radios
|
|
* - makeUI(flavor) → { Btn, Card, Input, Badge, Field, Estado }
|
|
*
|
|
* Los componentes viven UNA sola vez aquí; makeUI(flavor) los liga a las medidas
|
|
* exactas de cada página ('panel' escritorio, 'becario'/'checada' móvil) para que
|
|
* el resultado se vea idéntico al de hoy. El rediseño se hace tocando este archivo.
|
|
*/
|
|
window.Theme = (function () {
|
|
var COLORS = {
|
|
bg: "#EEF1F4", surface: "#FFFFFF", ink: "#1F2933", inkSoft: "#616E7C",
|
|
border: "#DDE2E7", primary: "#2A6FB0", primaryDark: "#1E4E7E",
|
|
success: "#2E7D5B", successBg: "#E7F3EC", warn: "#B7791F", warnBg: "#FBF2E1",
|
|
danger: "#C0392B", dangerBg: "#FBEBE9", chip: "#F0F2F5", accentBg: "#EAF2FA",
|
|
};
|
|
|
|
var FONT = "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif";
|
|
|
|
var SPACE = { none: "0", xs: "4px", sm: "8px", md: "12px", lg: "16px", xl: "20px", "2xl": "24px", "3xl": "32px" };
|
|
var RADIUS = { sm: "8px", md: "10px", lg: "12px", xl: "14px", "2xl": "16px", pill: "999px" };
|
|
|
|
// ── Rediseño móvil: paleta crema + fuentes de marca (flavors 'checada' y 'becario') ──
|
|
// No afecta a panel: sus componentes siguen usando COLORS/FONT.
|
|
var CREAM = {
|
|
bg: "#F3EBDD",
|
|
bgGradient: "radial-gradient(120% 80% at 50% -10%, #FBF5EA 0%, #F3EBDD 55%, #EFE5D3 100%)",
|
|
surface: "#FFFFFF", cardBorder: "#F0E8DA",
|
|
ink: "#2E2A24", inkSoft: "#8A8175", label: "#6E6559", placeholder: "#B4A99A", line: "#E4D9C6",
|
|
brand: "#16406B", primary: "#2E77B8", primaryDark: "#25689F",
|
|
green: "#2F8A63", greenDark: "#287854", amber: "#B7791F", danger: "#C0392B",
|
|
greenTint: "#E4F1E9", blueTint: "#E7F0F8", amberTint: "#FBF0DC", dangerTint: "#FBEBE8",
|
|
errBg: "#FBEBE8", errBorder: "#F3D3CC", errText: "#B4362A",
|
|
warnBg: "#FBF0DC", warnBorder: "#EFD9A8", warnText: "#8A5A12",
|
|
inputBorder: "#ECE3D4", inputBg: "#FBF8F2", track: "#EDE4D5", dashed: "#C7DBEC",
|
|
// Portal del becario:
|
|
neutralTint: "#EEE7D9", softTint: "#F1EADC", // píldora neutra / círculos y toggle
|
|
okBorder: "#C4E3D2", okText: "#207A52", // nota de éxito verde
|
|
metaBorder: "#CDE7D9", gold: "#F2B705", goldDark: "#E0A800", // "meta cumplida" + estrella
|
|
};
|
|
var FONT_TITLE = "'Bricolage Grotesque', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif";
|
|
var FONT_BODY = "'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif";
|
|
|
|
// Vocabulario de tonos de Badge, unión de los dos que usaban panel y becario.
|
|
var TONES = {
|
|
chip: { bg: COLORS.chip, color: COLORS.inkSoft },
|
|
success: { bg: COLORS.successBg, color: COLORS.success },
|
|
warn: { bg: COLORS.warnBg, color: COLORS.warn },
|
|
danger: { bg: COLORS.dangerBg, color: COLORS.danger },
|
|
primary: { bg: COLORS.accentBg, color: COLORS.primaryDark },
|
|
pendiente: { bg: COLORS.warnBg, color: COLORS.warn },
|
|
activo: { bg: COLORS.successBg, color: COLORS.success },
|
|
baja: { bg: COLORS.chip, color: COLORS.inkSoft },
|
|
};
|
|
|
|
// Medidas exactas por página (reproducen el look actual, píxel por píxel).
|
|
var FLAVORS = {
|
|
panel: {
|
|
card: { radius: RADIUS.lg, pad: "20px", shadow: "0 1px 3px rgba(0,0,0,0.04)", mb: undefined },
|
|
input: { pad: "9px 11px", radius: RADIUS.sm, font: "14px" },
|
|
badge: { pad: "2px 9px", nowrap: true },
|
|
btn: {
|
|
block: false, weight: 600, radius: RADIUS.sm, disabledInk: true, transition: "opacity .15s",
|
|
sizes: { sm: { pad: "6px 12px", font: "13px" }, md: { pad: "10px 18px", font: "14px" } },
|
|
defaultSize: "md",
|
|
},
|
|
},
|
|
becario: {
|
|
card: { radius: RADIUS.xl, pad: "18px", shadow: undefined, mb: "14px" },
|
|
input: { pad: "12px 14px", radius: RADIUS.md, font: "16px" },
|
|
badge: { pad: "3px 10px", nowrap: false },
|
|
btn: {
|
|
block: true, weight: 700, radius: RADIUS.md, disabledInk: false, transition: undefined,
|
|
sizes: { md: { pad: "13px", font: "15px" } }, defaultSize: "md",
|
|
},
|
|
},
|
|
checada: {
|
|
card: { radius: RADIUS["2xl"], pad: "24px", shadow: undefined, mb: undefined },
|
|
input: { pad: "13px 14px", radius: RADIUS.md, font: "16px" },
|
|
badge: { pad: "3px 10px", nowrap: false },
|
|
btn: {
|
|
block: true, weight: 700, radius: RADIUS.md, disabledInk: false, transition: undefined,
|
|
sizes: { md: { pad: "14px", font: "16px" } }, defaultSize: "md",
|
|
},
|
|
},
|
|
};
|
|
|
|
function btnVariant(v) {
|
|
switch (v) {
|
|
case "success": return { bg: COLORS.success, color: "#fff", border: "none" };
|
|
case "danger": return { bg: COLORS.danger, color: "#fff", border: "none" };
|
|
case "ghost": return { bg: "transparent", color: COLORS.primary, border: "1px solid " + COLORS.border };
|
|
case "subtle": return { bg: COLORS.chip, color: COLORS.ink, border: "none" };
|
|
default: return { bg: COLORS.primary, color: "#fff", border: "none" };
|
|
}
|
|
}
|
|
|
|
// ── Íconos de línea del rediseño (name -> función(opts) -> <svg>) ──
|
|
// opts: { size, color, sw (stroke-width), style }. Sin dependencias externas.
|
|
function makeIcons(React) {
|
|
var h = React.createElement;
|
|
function ic(paths, o) {
|
|
o = o || {};
|
|
var kids = paths.map(function (p, i) { return h(p[0], Object.assign({ key: i }, p[1])); });
|
|
return h("svg", {
|
|
width: o.size || 28, height: o.size || 28, viewBox: "0 0 24 24", fill: "none",
|
|
stroke: o.color || "currentColor", strokeWidth: o.sw || 1.7,
|
|
strokeLinecap: "round", strokeLinejoin: "round", style: o.style,
|
|
}, kids);
|
|
}
|
|
return {
|
|
nfc: function (o) { return ic([["rect",{x:6,y:2.5,width:9,height:19,rx:2.5}],["path",{d:"M18 8a5 5 0 0 1 0 8"}],["path",{d:"M20.6 5.4a8.5 8.5 0 0 1 0 13.2"}]], o); },
|
|
sunrise: function (o) { return ic([["path",{d:"M12 2.6v2.6"}],["path",{d:"M4.7 8 6.3 9.6"}],["path",{d:"M19.3 8 17.7 9.6"}],["path",{d:"M2.4 15h3"}],["path",{d:"M18.6 15h3"}],["path",{d:"M8 15a4 4 0 0 1 8 0"}],["path",{d:"M1.6 19h20.8"}]], o); },
|
|
moon: function (o) { return ic([["path",{d:"M20 14.6A8 8 0 1 1 9.4 4a6.5 6.5 0 0 0 10.6 10.6z"}]], o); },
|
|
check: function (o) { return ic([["path",{d:"M21.6 11.1V12a9.6 9.6 0 1 1-5.7-8.8"}],["path",{d:"M8.6 11.5 12 15l9.6-9.6"}]], o); },
|
|
hourglass: function (o) { return ic([["path",{d:"M6.5 3h11"}],["path",{d:"M6.5 21h11"}],["path",{d:"M7.5 3v3.1a5 5 0 0 0 2.8 4.5L12 12l1.7-1.4A5 5 0 0 0 16.5 6.1V3"}],["path",{d:"M7.5 21v-3.1a5 5 0 0 1 2.8-4.5L12 12l1.7 1.4a5 5 0 0 1 2.5 4.5V21"}]], o); },
|
|
clock: function (o) { return ic([["circle",{cx:12,cy:12,r:8.6}],["path",{d:"M12 7.2V12l3.2 2"}]], o); },
|
|
refresh: function (o) { return ic([["path",{d:"M3.2 12a8.8 8.8 0 0 1 15.1-6.1L21 8"}],["path",{d:"M21 3.6V8h-4.4"}],["path",{d:"M20.8 12a8.8 8.8 0 0 1-15.1 6.1L3 16"}],["path",{d:"M3 20.4V16h4.4"}]], o); },
|
|
lock: function (o) { o = o || {}; return ic([["rect",{x:4.5,y:10.5,width:15,height:10.5,rx:3}],["path",{d:"M8 10.5V7a4 4 0 0 1 8 0v3.5"}],["circle",{cx:12,cy:15.6,r:1.4,fill:o.color||"currentColor",stroke:"none"}]], o); },
|
|
alertCircle: function (o) { return ic([["circle",{cx:12,cy:12,r:9.2}],["path",{d:"M12 7.6v5"}],["path",{d:"M12 16.2h.01"}]], o); },
|
|
alertTriangle: function (o) { return ic([["path",{d:"M12 3 2.6 20h18.8L12 3z"}],["path",{d:"M12 9.6v4"}],["path",{d:"M12 17h.01"}]], o); },
|
|
calendar: function (o) { return ic([["rect",{x:3.5,y:5,width:17,height:16,rx:3}],["path",{d:"M3.5 9.5h17"}],["path",{d:"M8 3v4"}],["path",{d:"M16 3v4"}]], o); },
|
|
star: function (o) {
|
|
o = o || {};
|
|
return h("svg", { width: o.size || 20, height: o.size || 20, viewBox: "0 0 24 24",
|
|
fill: o.color || CREAM.gold, stroke: o.stroke || CREAM.goldDark, strokeWidth: 1, strokeLinejoin: "round", style: o.style },
|
|
h("path", { d: "M12 2.4l2.9 5.9 6.5.95-4.7 4.57 1.1 6.48L12 17.8l-5.8 3.06 1.1-6.48L2.6 9.25l6.5-.95z" }));
|
|
},
|
|
spinner: function (o) {
|
|
o = o || {};
|
|
return h("svg", { width: o.size || 18, height: o.size || 18, viewBox: "0 0 24 24", fill: "none",
|
|
style: Object.assign({ animation: "tb-spin .8s linear infinite" }, o.style || {}) },
|
|
[ h("circle", { key: 0, cx: 12, cy: 12, r: 9, stroke: o.track || "rgba(255,255,255,.35)", strokeWidth: 3 }),
|
|
h("path", { key: 1, d: "M21 12a9 9 0 0 0-9-9", stroke: o.color || "#fff", strokeWidth: 3, strokeLinecap: "round" }) ]);
|
|
},
|
|
};
|
|
}
|
|
|
|
// ── Set de componentes "cream" para el flavor 'checada' (rediseño visual) ──
|
|
// Devuelve su propia API (Logo, IconBadge, Card, Btn, Input, Aviso, Estado,
|
|
// palette, fonts, icons). Independiente del camino panel/becario.
|
|
function makeCream(React) {
|
|
var h = React.createElement;
|
|
var C = CREAM;
|
|
var fonts = { title: FONT_TITLE, body: FONT_BODY };
|
|
var icons = makeIcons(React);
|
|
// tone (string) -> stroke del glifo, tinte del círculo, color del título.
|
|
var STATE = {
|
|
green: { stroke: C.green, tint: C.greenTint, title: C.green },
|
|
blue: { stroke: C.primary, tint: C.blueTint, title: C.ink },
|
|
amber: { stroke: C.amber, tint: C.amberTint, title: C.amber },
|
|
danger: { stroke: C.danger, tint: C.dangerTint, title: C.danger },
|
|
neutral: { stroke: C.inkSoft, tint: C.softTint, title: C.ink },
|
|
};
|
|
|
|
function Logo(props) {
|
|
return h("img", { src: "logo-taboada.png", alt: "Fundación Taboada",
|
|
style: Object.assign({ height: "108px", width: "auto", display: "block" }, (props && props.style) || {}) });
|
|
}
|
|
|
|
function IconBadge(props) {
|
|
var t = STATE[props.tone] || STATE.blue;
|
|
var sz = props.size || 64;
|
|
var glyph = icons[props.icon] ? icons[props.icon]({ color: t.stroke, size: Math.round(sz * 0.47), sw: 1.7 }) : null;
|
|
return h("div", { style: { width: sz + "px", height: sz + "px", borderRadius: "50%", background: t.tint,
|
|
display: "flex", alignItems: "center", justifyContent: "center", margin: "0 auto 16px" } }, glyph);
|
|
}
|
|
|
|
function Card(props) {
|
|
return h("div", { style: Object.assign({
|
|
background: C.surface, border: "1px solid " + C.cardBorder, borderRadius: "26px",
|
|
padding: "24px", boxShadow: "0 20px 44px -28px rgba(33,28,22,.35)",
|
|
}, props.style || {}) }, props.children);
|
|
}
|
|
|
|
function Btn(props) {
|
|
var ghost = props.variant === "ghost"; // secundario: contorno azul, sin relleno
|
|
var success = props.variant === "success";
|
|
var disabled = props.disabled;
|
|
var style = {
|
|
width: "100%", boxSizing: "border-box", padding: "15px", borderRadius: "16px",
|
|
fontFamily: fonts.body, fontSize: "15px", fontWeight: 700,
|
|
cursor: disabled ? "not-allowed" : (props.loading ? "progress" : "pointer"),
|
|
display: "flex", alignItems: "center", justifyContent: "center", gap: "10px",
|
|
};
|
|
if (ghost) {
|
|
style.background = "transparent";
|
|
style.border = "1.5px solid " + (disabled ? "#C6CFD8" : C.primary);
|
|
style.color = disabled ? "#B7C4D2" : C.primary;
|
|
style.boxShadow = "none";
|
|
} else {
|
|
var bg = success ? C.green : C.primary;
|
|
var shadow = success ? "0 12px 22px -10px rgba(47,138,99,.75)" : "0 12px 22px -10px rgba(46,119,184,.75)";
|
|
style.border = "none";
|
|
style.background = disabled ? "#C6CFD8" : bg;
|
|
style.color = disabled ? "#F4F8FC" : "#fff";
|
|
style.boxShadow = disabled ? "none" : shadow;
|
|
}
|
|
var kids = [];
|
|
if (props.loading) kids.push(h("span", { key: "s", style: { display: "inline-flex" } },
|
|
icons.spinner({ size: 18, color: ghost ? C.primary : "#fff", track: ghost ? C.line : undefined })));
|
|
kids.push(h("span", { key: "t" }, props.children));
|
|
return h("button", { type: props.type || "button", onClick: props.onClick, disabled: disabled, style: style }, kids);
|
|
}
|
|
|
|
function Input(props) {
|
|
var rest = Object.assign({}, props); delete rest.style;
|
|
var style = Object.assign({
|
|
width: "100%", boxSizing: "border-box", padding: "14px 15px",
|
|
border: "1.5px solid " + C.inputBorder, borderRadius: "15px", background: C.inputBg,
|
|
fontFamily: fonts.body, fontSize: "15px", color: C.ink, outline: "none",
|
|
}, props.style || {});
|
|
return h("input", Object.assign(rest, { style: style }));
|
|
}
|
|
|
|
function Aviso(props) {
|
|
var v = props.variant;
|
|
var box = v === "warn" ? { bg: C.warnBg, bd: C.warnBorder, text: C.warnText, ink: C.amber }
|
|
: v === "success" ? { bg: C.greenTint, bd: C.okBorder, text: C.okText, ink: C.green }
|
|
: { bg: C.errBg, bd: C.errBorder, text: C.errText, ink: C.danger };
|
|
var glyph = icons[props.icon] ? icons[props.icon]({ color: box.ink, size: 18, style: { flexShrink: 0 } }) : null;
|
|
return h("div", { style: { display: "flex", gap: "10px", alignItems: "flex-start",
|
|
background: box.bg, border: "1px solid " + box.bd, borderRadius: "14px", padding: "11px 13px", marginBottom: "14px" } },
|
|
[ glyph ? h("span", { key: "i", style: { display: "inline-flex", flexShrink: 0, marginTop: "1px" } }, glyph) : null,
|
|
h("span", { key: "t", style: { fontFamily: fonts.body, fontSize: "13px", fontWeight: 500, color: box.text, lineHeight: 1.45 } }, props.children) ]);
|
|
}
|
|
|
|
// Patrón ícono-en-círculo + título + mensaje (+ progreso / acción opcionales).
|
|
// props.tone: "green" | "blue" | "amber" | "danger"; props.icon: nombre en icons.
|
|
function Estado(props) {
|
|
var t = STATE[props.tone] || STATE.blue;
|
|
var cardStyle = { textAlign: "center", padding: "28px 24px" };
|
|
if (props.dashed) cardStyle.border = "1.5px dashed " + C.dashed;
|
|
var kids = [
|
|
h(IconBadge, { key: "i", icon: props.icon, tone: props.tone }),
|
|
h("h2", { key: "t", style: { margin: "0 0 8px", fontFamily: fonts.title, fontWeight: 600,
|
|
fontSize: "21px", color: t.title, letterSpacing: "-.01em", lineHeight: 1.2 } }, props.title),
|
|
];
|
|
if (props.sub) kids.push(h("p", { key: "s", style: { margin: 0, fontFamily: fonts.body,
|
|
fontWeight: 400, fontSize: "14px", color: C.inkSoft, lineHeight: 1.55 } }, props.sub));
|
|
if (typeof props.progress === "number") kids.push(
|
|
h("div", { key: "pg", style: { height: "8px", borderRadius: "99px", background: C.track, marginTop: "16px", overflow: "hidden" } },
|
|
h("div", { style: { height: "100%", width: Math.max(0, Math.min(100, props.progress)) + "%", borderRadius: "99px", background: C.green } })));
|
|
if (props.action) kids.push(h("div", { key: "a", style: { marginTop: "18px" } }, props.action));
|
|
return Card({ style: cardStyle, children: kids });
|
|
}
|
|
|
|
// Píldora de estado. tone = string de estado real (activo/pendiente/cerrada/
|
|
// abierta/revision/baja/autorizada/rechazada); mapea al color, no al revés.
|
|
var BADGE = {
|
|
activo: [C.greenTint, C.green], cerrada: [C.greenTint, C.green], autorizada: [C.greenTint, C.green],
|
|
pendiente: [C.amberTint, C.amber], revision: [C.amberTint, C.amber],
|
|
abierta: [C.neutralTint, C.inkSoft],
|
|
baja: [C.dangerTint, C.danger], rechazada: [C.dangerTint, C.danger],
|
|
};
|
|
function StatusBadge(props) {
|
|
var t = BADGE[props.tone] || [C.neutralTint, C.inkSoft];
|
|
return h("span", { style: { display: "inline-block", padding: "3px 10px", borderRadius: "99px",
|
|
fontFamily: fonts.body, fontSize: "11px", fontWeight: 600, background: t[0], color: t[1], whiteSpace: "nowrap" } }, props.children);
|
|
}
|
|
|
|
// Tarjeta de horas con barra de avance. Al 100% muestra "¡Meta cumplida!".
|
|
// Pinta valores del backend (total/meta/porcentaje/sub); no calcula nada.
|
|
function HorasCard(props) {
|
|
var pct = Math.max(0, Math.min(100, props.porcentaje || 0));
|
|
var done = (props.porcentaje || 0) >= 100;
|
|
var kids = [];
|
|
if (done) {
|
|
kids.push(h("div", { key: "stripe", style: { position: "absolute", top: 0, left: 0, right: 0, height: "4px",
|
|
background: "linear-gradient(90deg," + C.green + "," + C.gold + ")" } }));
|
|
kids.push(h("div", { key: "hdr", style: { display: "flex", alignItems: "center", gap: "8px", marginBottom: "8px" } },
|
|
[ h("span", { key: "s", style: { display: "inline-flex" } }, icons.star({ size: 20 })),
|
|
h("span", { key: "t", style: { fontFamily: fonts.title, fontWeight: 700, fontSize: "15px", color: C.green } }, "¡Meta cumplida!") ]));
|
|
} else {
|
|
kids.push(h("div", { key: "lbl", style: { fontFamily: fonts.body, fontWeight: 500, fontSize: "13px", color: C.inkSoft, marginBottom: "4px" } }, "Horas acumuladas"));
|
|
}
|
|
kids.push(h("div", { key: "num", style: { fontFamily: fonts.title, fontWeight: 700, fontSize: "30px", color: C.brand, letterSpacing: "-.01em", lineHeight: 1.1 } },
|
|
[ props.total, " ", h("span", { key: "m", style: { fontFamily: fonts.body, fontWeight: 500, fontSize: "15px", color: C.inkSoft } }, "de " + props.meta) ]));
|
|
kids.push(h("div", { key: "trk", style: { height: "9px", background: C.track, borderRadius: "99px", overflow: "hidden", margin: "13px 0 8px" } },
|
|
h("div", { style: { height: "100%", width: pct + "%", background: done ? C.green : C.primary, borderRadius: "99px" } })));
|
|
kids.push(h("div", { key: "sub", style: { fontFamily: fonts.body, fontWeight: 400, fontSize: "12px", color: done ? C.green : C.inkSoft } }, props.sub));
|
|
return h("div", { style: { background: C.surface, border: "1px solid " + (done ? C.metaBorder : C.cardBorder),
|
|
borderRadius: "20px", padding: "20px", boxShadow: "0 16px 34px -28px rgba(33,28,22,.3)", position: "relative", overflow: "hidden" } }, kids);
|
|
}
|
|
|
|
return { Logo: Logo, IconBadge: IconBadge, Card: Card, Btn: Btn, Input: Input,
|
|
Aviso: Aviso, Estado: Estado, StatusBadge: StatusBadge, HorasCard: HorasCard,
|
|
palette: C, fonts: fonts, icons: icons };
|
|
}
|
|
|
|
function makeUI(flavor) {
|
|
var React = window.React;
|
|
var h = React.createElement;
|
|
if (flavor === "checada" || flavor === "becario") return makeCream(React); // rediseño móvil: set cream
|
|
var F = FLAVORS[flavor];
|
|
if (!F) throw new Error("Theme.makeUI: flavor desconocido '" + flavor + "'");
|
|
|
|
function Card(props) {
|
|
var base = {
|
|
background: COLORS.surface, border: "1px solid " + COLORS.border,
|
|
borderRadius: F.card.radius, padding: F.card.pad,
|
|
boxShadow: F.card.shadow, marginBottom: F.card.mb,
|
|
};
|
|
return h("div", { style: Object.assign(base, props.style || {}) }, props.children);
|
|
}
|
|
|
|
function Btn(props) {
|
|
var v = btnVariant(props.variant);
|
|
var size = F.btn.sizes[props.size || F.btn.defaultSize] || F.btn.sizes[F.btn.defaultSize];
|
|
var disabled = props.disabled;
|
|
var style = {
|
|
padding: size.pad, borderRadius: F.btn.radius,
|
|
background: disabled ? COLORS.border : v.bg,
|
|
color: disabled && F.btn.disabledInk ? COLORS.inkSoft : v.color,
|
|
border: v.border,
|
|
fontFamily: FONT, fontSize: size.font, fontWeight: F.btn.weight,
|
|
cursor: disabled ? "not-allowed" : "pointer",
|
|
transition: F.btn.transition,
|
|
};
|
|
if (F.btn.block) style.width = "100%";
|
|
return h("button", { type: props.type || "button", onClick: props.onClick, disabled: disabled, style: style }, props.children);
|
|
}
|
|
|
|
function Input(props) {
|
|
var rest = Object.assign({}, props);
|
|
delete rest.style;
|
|
var style = Object.assign({
|
|
width: "100%", padding: F.input.pad, borderRadius: F.input.radius,
|
|
border: "1px solid " + COLORS.border, fontSize: F.input.font,
|
|
fontFamily: FONT, color: COLORS.ink, boxSizing: "border-box", outline: "none",
|
|
}, props.style || {});
|
|
return h("input", Object.assign(rest, { style: style }));
|
|
}
|
|
|
|
function Badge(props) {
|
|
var t = TONES[props.tone] || TONES.chip;
|
|
var style = {
|
|
background: t.bg, color: t.color, padding: F.badge.pad,
|
|
borderRadius: RADIUS.pill, fontSize: "12px", fontWeight: 700,
|
|
};
|
|
if (F.badge.nowrap) style.whiteSpace = "nowrap";
|
|
return h("span", { style: style }, props.children);
|
|
}
|
|
|
|
function Field(props) {
|
|
return h("label", { style: { display: "block", marginBottom: "12px" } },
|
|
h("span", { style: { display: "block", fontSize: "13px", fontWeight: 600, color: COLORS.inkSoft, marginBottom: "5px" } }, props.label),
|
|
props.children
|
|
);
|
|
}
|
|
|
|
// Patrón ícono + título + mensaje (+ botón opcional) de las pantallas de estado.
|
|
// `tone` es un COLOR (no un tono de badge): tiñe el título.
|
|
function Estado(props) {
|
|
var kids = [
|
|
h("div", { key: "e", style: { fontSize: "44px", marginBottom: "8px" } }, props.emoji),
|
|
h("h2", { key: "t", style: { margin: "0 0 6px", color: props.tone || COLORS.ink, fontSize: "20px" } }, props.title),
|
|
];
|
|
if (props.sub) kids.push(h("p", { key: "s", style: { margin: 0, color: COLORS.inkSoft, fontSize: "14px", lineHeight: 1.5 } }, props.sub));
|
|
if (props.action) kids.push(h("div", { key: "a", style: { marginTop: "16px" } }, props.action));
|
|
return Card({ style: { textAlign: "center" }, children: kids });
|
|
}
|
|
|
|
return { Btn: Btn, Card: Card, Input: Input, Badge: Badge, Field: Field, Estado: Estado };
|
|
}
|
|
|
|
return { COLORS: COLORS, FONT: FONT, SPACE: SPACE, RADIUS: RADIUS, makeUI: makeUI };
|
|
})();
|