// Shared small components for Estudia con Carol UI kit.
// All exposed on window so other Babel scripts can use them.
const { useState, useEffect, useRef } = React;
// ----- Icon helpers (inline Lucide-style SVGs, stroke 1.5) -----
const ICONS = {
book: <>>,
folder: <>>,
file: <>>,
pencil: <>>,
check: <>>,
star: <>>,
flame: <>>,
search: <>>,
user: <>>,
lock: <>>,
chevron: <>>,
chevronL: <>>,
chevronD: <>>,
plus: <>>,
upload: <>>,
download: <>>,
calendar: <>>,
clock: <>>,
msg: <>>,
sitemap: <>>,
more: <>>,
arrow: <>>,
bookmark: <>>,
};
function Icon({ name, size = 18, color, strokeWidth = 1.5, style }) {
const path = ICONS[name];
if (!path) return null;
return (
);
}
// ----- Button -----
function Button({ variant = 'primary', size = 'md', icon, iconRight, children, onClick, disabled, type = 'button', style }) {
const styles = {
display: 'inline-flex', alignItems: 'center', gap: 8,
padding: size === 'sm' ? '5px 10px' : '9px 14px',
borderRadius: 'var(--r-md)',
font: size === 'sm' ? 'var(--type-ui-sm)' : 'var(--type-ui)',
cursor: disabled ? 'not-allowed' : 'pointer',
border: '1px solid transparent',
transition: 'all var(--t-fast) var(--ease)',
opacity: disabled ? 0.4 : 1,
...(variant === 'primary' && { background: 'var(--terracotta)', color: '#fff' }),
...(variant === 'secondary' && { background: 'var(--bg-surface)', color: 'var(--ink)', borderColor: 'var(--line)' }),
...(variant === 'dark' && { background: 'var(--forest)', color: '#FBF8F0' }),
...(variant === 'ghost' && { background: 'transparent', color: 'var(--ink)' }),
...style,
};
return (
);
}
// ----- Chip (subject) -----
function Chip({ subject, active, onClick, count }) {
const data = (window.ECC_DATA.SUBJECTS).find(s => s.id === subject);
if (!data) return null;
const filled = active;
return (
);
}
// ----- Badge -----
function Badge({ kind, children }) {
const map = {
'new': { fg: 'var(--terracotta-deep)', bg: 'var(--terracotta-soft)' },
'in-progress': { fg: 'var(--warning)', bg: '#F7E6CB' },
'done': { fg: 'var(--success)', bg: '#E5EDD8' },
'danger': { fg: 'var(--danger)', bg: '#F2D8D2' },
'default': { fg: 'var(--ink-2)', bg: 'var(--bg-muted)' },
};
const c = map[kind] || map.default;
return (
{children}
);
}
// ----- Avatar -----
function Avatar({ initials, size = 28, color = 'var(--forest)' }) {
return (
{initials}
);
}
// ----- Label -----
function Label({ children, style }) {
return {children};
}
// ----- KindIcon (returns icon name for a material kind) -----
function kindIcon(kind) {
const k = window.ECC_DATA.KINDS[kind];
return k ? k.icon : 'file';
}
Object.assign(window, { Icon, Button, Chip, Badge, Avatar, Label, kindIcon });