diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 48054ca..f31dce3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,3 +25,29 @@ jobs: run: | echo "### rblez-ui v$(node -p "require('./package.json').version") · ${GITHUB_SHA::7}" >> "$GITHUB_STEP_SUMMARY" du -sh apps/preview/dist >> "$GITHUB_STEP_SUMMARY" + patch: + name: Patch snapshots + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Checkout rblez/patch + uses: actions/checkout@v4 + with: + repository: rblez/patch + path: .patch-cli + - uses: oven-sh/setup-bun@v2 + - name: Link patch CLI + working-directory: .patch-cli + run: | + bun install + bun link + echo "$HOME/.bun/bin" >> "$GITHUB_PATH" + - name: patch test design/*/ + run: | + fail=0 + for f in design/*/*.pat; do + echo "::group::$f" + patch test "$f" || fail=1 + echo "::endgroup::" + done + exit $fail diff --git a/CHANGELOG.md b/CHANGELOG.md index 35eac73..eb59e92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,14 @@ Todos los cambios notables de rblez-ui. Formato basado en [Keep a Changelog](htt - Header de la docs: se apilaba en dos filas (logo y versión arriba, búsqueda/Star abajo) y el logo quedaba cortado arriba, en móvil y en escritorio. Causa: `.top` no tenía ninguna regla base (ni `display`, ni altura, ni padding), solo ajustes sueltos en media queries. Ahora `.top` es una fila `sticky` de 56px (`display: flex; justify-content: space-between`) con fondo difuminado y borde inferior, como `.pv__bar`. ### Added +- `Grid` y `GridItem`: rejillas responsive con container queries (480 / 768 / 1024 / 1280px): `auto-fit` / `auto-fill` por ancho mínimo (`min`), `columns` con columnas por breakpoint (`cols: { base, sm, md, lg, xl }`), `masonry` (columnas CSS), `bento` con `colSpan` / `rowSpan` y `split` con columna lateral (`sidebar`, `side`). Los spans anchos ocupan la fila entera por debajo de 768px. +- `Modal`: diálogo sobre `` nativo con focus trap, devolución del foco, `aria-modal` / `aria-labelledby` / `aria-describedby`, tamaños `sm` · `md` · `lg`, pie de acciones, cierre con Esc y clic en el fondo configurables y bloqueo de scroll. +- `BottomSheet`: hoja inferior para móvil con asa para arrastrar (y flechas ↑/↓), puntos de anclaje (`snapPoints`, `snap`), cerrar arrastrando, fondo, focus trap, Esc, bloqueo de scroll y padding de safe-area. +- `Select`: select accesible con listbox propio (`role="combobox"`), teclado completo (flechas, Home/End, PageUp/PageDown, búsqueda por tecleo, Enter/Esc/Tab), `aria-activedescendant`, iconos, opciones deshabilitadas, búsqueda opcional (`searchable`, sin tildes ni mayúsculas) e input oculto para formularios. Mismo aspecto que `Input`. +- `Toast`: `` (región `aria-live="polite"`, `position`, `max`) y `toast()` con variantes `default` · `success` · `warning` · `danger`, título, descripción, acción, duración, cierre, apilado y pausa al pasar el ratón o con el foco. El store es agnóstico al framework y vive en `@rblez-ui/tokens`. +- Grupo «Overlay» en la docs; demos y páginas (`/ui//`) para los cinco componentes, en español e inglés. +- Versiones Patch en `design/grid`, `design/modal`, `design/bottom-sheet`, `design/select` y `design/toast` con casos de estado (claro/oscuro, abierto/cerrado, opción elegida, variantes…) y sus snapshots. +- CI: job «Patch snapshots» que ejecuta `patch test` sobre cada `design/*/`. - `NotFound`: página 404 con un 404 isométrico en 3D (vector generado desde Inter), rejilla isométrica y tema claro/oscuro. La docs lo usa para rutas inexistentes. - Slider de componentes en móvil (deslizar o tocar) y paginador anterior/siguiente. - Landing en la introducción con animaciones GSAP (timeline y ScrollTrigger) y Motion (inView, hover, springs). @@ -21,6 +29,7 @@ Todos los cambios notables de rblez-ui. Formato basado en [Keep a Changelog](htt - Búsqueda en la cabecera en escritorio (⌘K / Ctrl+K) con paleta de comandos. ### Changed +- `ProfileSettings`: los iconos de las baldosas de color son rellenos (Heroicons solid vía ``), en blanco sobre la baldosa, como en los ajustes de Telegram; el icono de la pestaña activa también es relleno y las inactivas siguen en línea. Las píldoras superiores (QR, buscar, más) y el chevron siguen en línea. La versión Patch (`design/profile-settings`) usa glifos rellenos equivalentes y sus snapshots se han regenerado. - El repo pasa a `rblez/ui` y la ruta a `/ui/`. - La licencia se integra en Acerca de. - Preview sin selector de framework. diff --git a/README.md b/README.md index 94d41af..e573b7c 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,10 @@ Docs: **[www.rblez.com/ui](https://www.rblez.com/ui/)** · [GitHub Pages](https: | Grupo | Componentes | |---|---| | IA / AI | `PromptInput` | -| Formularios / Forms | `Button`, `Input`, `Textarea`, `Switch` | -| Layout | `Card`, `Sidebar`, `Footer` | -| Feedback | `Badge`, `Kbd` | +| Formularios / Forms | `Button`, `Input`, `Textarea`, `Switch`, `Select` | +| Layout | `Grid`, `Card`, `Sidebar`, `Footer`, `ProfileSettings`, `NotFound` | +| Overlay | `Modal`, `BottomSheet` | +| Feedback | `Badge`, `Kbd`, `Toast` (`Toaster` + `toast()`) | | Base | `Icon` (Heroicons, línea y relleno), tokens | ## Paquetes / Packages @@ -50,6 +51,7 @@ packages/svelte Svelte 5 packages/react React 18+ apps/preview docs (Vite + Svelte), base /ui/ scripts/og plantilla de la imagen Open Graph +design/ versión Patch de cada componente (Figma + tests de estado) ``` ## Desarrollo diff --git a/SKILL.md b/SKILL.md index 5094737..89e83d0 100644 --- a/SKILL.md +++ b/SKILL.md @@ -64,17 +64,22 @@ Light: bg `#f7f7f4`, ink `#26251e`. Dark: bg `#14120b`, ink `#edecec`. | `Input` | `value`, `label`, `hint`, `error`, `size`, `prefix` / `suffix` | `error` sets `aria-invalid`. | | `Textarea` | `value`, `label`, `hint`, `error`, `rows` | | | `Switch` | `checked`, `label`, `disabled` | `role="switch"`. | +| `Select` | `value`, `options: { value, label, disabled?, icon? }[]`, `label`, `hint`, `error`, `placeholder`, `size`, `searchable`, `name`, `onchange` | Own listbox (`role="combobox"` + `listbox`): arrows, Home/End, PageUp/Down, typeahead, Enter/Esc/Tab, `aria-activedescendant`. Same look as `Input`. | +| `Modal` | `open`, `onclose`, `title`, `description`, `size: sm · md · lg`, `closeOnBackdrop`, `closeOnEsc`, `showClose`, `footer` | Native `` + `showModal()`: focus trap, focus return, `aria-modal`, `aria-labelledby`, scroll lock. | +| `BottomSheet` | `open`, `onclose`, `title`, `description`, `snapPoints` (fractions of the viewport), `snap`, `onsnapchange`, `dismissible`, `footer` | Drag handle (↑/↓ keys), drag to dismiss, backdrop, Esc, focus trap, scroll lock, safe-area padding. | | `Badge` | `variant: default · secondary · outline · brand · success · warning · danger`, `dot` | | | `Kbd` | children | Keyboard shortcuts. | +| `Toaster` + `toast()` | `position`, `max`, `label`; `toast(title \| options)`, `toast.success/warning/danger`, `toast.dismiss(id?)` | One `` per app; `aria-live="polite"`; options `{ title, description, variant, duration, action: { label, onClick }, dismissible }`; pauses on hover/focus. Store shared in `@rblez-ui/tokens`. | | `Card` | `title`, `description`, `footer` | | +| `Grid` | `variant: auto-fit · auto-fill · columns · masonry · bento · split`, `cols` (number or `{ base, sm, md, lg, xl }`), `min`, `gap`, `sidebar`, `side`, `rowHeight`, `as` | Container queries (480/768/1024/1280). `GridItem` with `colSpan` / `rowSpan`; wide spans take the full row below 768px. | | `Sidebar` | `sections: { title, items: { label, href, badge? }[] }[]`, `active`, `onnavigate` | `aria-current="page"` on the active item. | | `Footer` | `columns: { title, links }[]`, `legal`, `logo`, `logoHref` | Linear-style; legal moves to a bottom bar on mobile. | | `PromptInput` | `value`, `plan`, `placeholder` (string or rotating string[]), `submitLabel`, `theme`, `onsubmit(d: { value, plan, files })`, `ondictate` | AI composer: attachments, plan mode, dictation; Enter sends, Shift+Enter new line. | -| `ProfileSettings` | `profile`, `sections`, `tabs`, `activeTab`, `title`, `footer`, `onselect`, `onavatar`, `onqr`, `onsearch`, `onmore`, `ontab` | Telegram-style settings screen; title compacts on scroll; floating tab bar. Row colors: `blue sky indigo cyan green orange amber red rose violet purple gray`. | +| `ProfileSettings` | `profile`, `sections`, `tabs`, `activeTab`, `title`, `footer`, `onselect`, `onavatar`, `onqr`, `onsearch`, `onmore`, `ontab` | Telegram-style settings screen; title compacts on scroll; floating tab bar. Tile icons are filled (white on the color tile); the active tab icon is filled, inactive tabs and top pills stay line. Row colors: `blue sky indigo cyan green orange amber red rose violet purple gray`. | | `NotFound` | `title`, `description`, `actionLabel`, `href`, `grid`, `onaction` | 404 page: isometric 3D "404" vector + isometric grid. Regenerate the art with `python3 scripts/notfound/gen.py`. | | `Icon` | `name` (curated) or `icon` (any Heroicon), `variant: line · fill`, `size`, `strokeWidth`, `label` | See §5. | -Types live in `@rblez-ui/tokens` (`ButtonVariant`, `SidebarSection`, `FooterColumn`, `SettingsSection`, `SettingsItem`, `SettingsTab`, `SettingsProfile`, `PromptSubmit`, `IconName`, `IconNode`, …). +Types live in `@rblez-ui/tokens` (`ButtonVariant`, `SidebarSection`, `FooterColumn`, `SettingsSection`, `SettingsItem`, `SettingsTab`, `SettingsProfile`, `PromptSubmit`, `IconName`, `IconNode`, `GridVariant`, `GridCols`, `ModalSize`, `SelectOption`, `ToastOptions`, `ToastVariant`, `ToastPosition`, …). ## 5. Icons (Heroicons) @@ -129,7 +134,7 @@ Line icons use stroke 2 at ≤16px and 1.5 above. Icon-only buttons need `aria-l 2. `packages/svelte/src/.svelte` and `packages/react/src/.tsx` with identical props; export both from each `index.ts`. 3. Demo in `apps/preview/src/demos/{svelte,react}/Demo.*` and an entry in `apps/preview/src/docs/registry.ts` (slug, name, group, description, props); English copy in `docs/i18n.svelte.ts`. 4. Regenerate OG images: `pnpm build && python3 scripts/og/render.py && pnpm build`. -5. Optional: a Patch version in `design//` with `*.test.json` state cases for Figma export and snapshot tests. +5. A Patch version in `design//` with `*.test.json` state cases for Figma export and snapshot tests (`patch test design//.pat`; CI runs every `design/*/`). 6. Add a line to `CHANGELOG.md` under **Unreleased**; open a PR (`feat(): …`). ## 9. Don'ts diff --git a/apps/preview/public/og/bottom-sheet.png b/apps/preview/public/og/bottom-sheet.png new file mode 100644 index 0000000..5744c26 Binary files /dev/null and b/apps/preview/public/og/bottom-sheet.png differ diff --git a/apps/preview/public/og/grid.png b/apps/preview/public/og/grid.png new file mode 100644 index 0000000..7e75268 Binary files /dev/null and b/apps/preview/public/og/grid.png differ diff --git a/apps/preview/public/og/modal.png b/apps/preview/public/og/modal.png new file mode 100644 index 0000000..0258b6d Binary files /dev/null and b/apps/preview/public/og/modal.png differ diff --git a/apps/preview/public/og/select.png b/apps/preview/public/og/select.png new file mode 100644 index 0000000..0ece30e Binary files /dev/null and b/apps/preview/public/og/select.png differ diff --git a/apps/preview/public/og/toast.png b/apps/preview/public/og/toast.png new file mode 100644 index 0000000..647a0a7 Binary files /dev/null and b/apps/preview/public/og/toast.png differ diff --git a/apps/preview/src/App.svelte b/apps/preview/src/App.svelte index 8d852f2..5f0b11b 100644 --- a/apps/preview/src/App.svelte +++ b/apps/preview/src/App.svelte @@ -55,7 +55,7 @@ return () => { removeEventListener("popstate", on); removeEventListener("click", click); }; }); - const groups = ["IA", "Formularios", "Layout", "Feedback"] as const; + const groups = ["IA", "Formularios", "Layout", "Overlay", "Feedback"] as const; const L = $derived(t()); $effect(() => { document.documentElement.lang = i18n.lang; }); const sections: SidebarSection[] = $derived([ diff --git a/apps/preview/src/demos/react/BottomSheetDemo.tsx b/apps/preview/src/demos/react/BottomSheetDemo.tsx new file mode 100644 index 0000000..52294af --- /dev/null +++ b/apps/preview/src/demos/react/BottomSheetDemo.tsx @@ -0,0 +1,23 @@ +import { useState } from "react"; +import { BottomSheet, Button, Switch } from "@rblez-ui/react"; + +export default function BottomSheetDemo() { + const [open, setOpen] = useState(false); + const [snap, setSnap] = useState(0); + return ( + <> +
+ +
+ setOpen(false)} snap={snap} onSnapChange={setSnap} snapPoints={[0.45, 0.9]} + title="Ajustes rápidos" description="Arrastra el asa para expandir o cerrar." + footer={}> +
+ + + +
+
+ + ); +} diff --git a/apps/preview/src/demos/react/GridDemo.tsx b/apps/preview/src/demos/react/GridDemo.tsx new file mode 100644 index 0000000..b3f4efb --- /dev/null +++ b/apps/preview/src/demos/react/GridDemo.tsx @@ -0,0 +1,51 @@ +import { useState } from "react"; +import { Button, Grid, GridItem } from "@rblez-ui/react"; +import type { GridVariant } from "@rblez-ui/tokens"; + +const variants: GridVariant[] = ["bento", "auto-fit", "columns", "masonry", "split"]; +const heights = [64, 112, 80, 136, 72, 96]; + +export default function GridDemo() { + const [variant, setVariant] = useState("bento"); + return ( +
+
+ {variants.map((v) => ( + + ))} +
+ + {variant === "bento" && ( + + 2 × 2 + 2 × 1 + 1 + 1 + 3 × 1 + 1 + + )} + {variant === "auto-fit" && ( + + {Array.from({ length: 6 }, (_, i) =>
min 140px · {i + 1}
)} +
+ )} + {variant === "columns" && ( + + {Array.from({ length: 6 }, (_, i) =>
1 · 2 · 3 col · {i + 1}
)} +
+ )} + {variant === "masonry" && ( + + {heights.map((h, i) =>
{i + 1}
)} +
+ )} + {variant === "split" && ( + + +
Contenido
+
+ )} +
+ ); +} diff --git a/apps/preview/src/demos/react/ModalDemo.tsx b/apps/preview/src/demos/react/ModalDemo.tsx new file mode 100644 index 0000000..3441371 --- /dev/null +++ b/apps/preview/src/demos/react/ModalDemo.tsx @@ -0,0 +1,20 @@ +import { useState } from "react"; +import { Button, Input, Modal } from "@rblez-ui/react"; + +export default function ModalDemo() { + const [open, setOpen] = useState(false); + return ( + <> +
+ +
+ setOpen(false)} title="Renombrar proyecto" description="El nombre aparece en la URL y en el panel." size="sm" + footer={<> + + + }> + + + + ); +} diff --git a/apps/preview/src/demos/react/SelectDemo.tsx b/apps/preview/src/demos/react/SelectDemo.tsx new file mode 100644 index 0000000..ce30974 --- /dev/null +++ b/apps/preview/src/demos/react/SelectDemo.tsx @@ -0,0 +1,28 @@ +import { useState } from "react"; +import { Select } from "@rblez-ui/react"; +import type { SelectOption } from "@rblez-ui/tokens"; + +const regions: SelectOption[] = [ + { value: "mad", label: "Madrid (eu-south)", icon: "globe" }, + { value: "fra", label: "Frankfurt (eu-central)", icon: "globe" }, + { value: "iad", label: "Virginia (us-east)", icon: "globe" }, + { value: "sfo", label: "San Francisco (us-west)", icon: "globe" }, + { value: "gru", label: "São Paulo (sa-east)", icon: "globe", disabled: true }, +]; +const roles: SelectOption[] = [ + { value: "owner", label: "Propietario" }, + { value: "admin", label: "Administrador" }, + { value: "member", label: "Miembro" }, + { value: "viewer", label: "Solo lectura" }, +]; + +export default function SelectDemo() { + const [region, setRegion] = useState("mad"); + const [role, setRole] = useState(); + return ( +
+ +
+ ); +} diff --git a/apps/preview/src/demos/react/ToastDemo.tsx b/apps/preview/src/demos/react/ToastDemo.tsx new file mode 100644 index 0000000..0cf0aa8 --- /dev/null +++ b/apps/preview/src/demos/react/ToastDemo.tsx @@ -0,0 +1,15 @@ +import { Button, Toaster, toast } from "@rblez-ui/react"; + +export default function ToastDemo() { + return ( + <> +
+ + + + +
+ + + ); +} diff --git a/apps/preview/src/demos/svelte/BottomSheetDemo.svelte b/apps/preview/src/demos/svelte/BottomSheetDemo.svelte new file mode 100644 index 0000000..1699193 --- /dev/null +++ b/apps/preview/src/demos/svelte/BottomSheetDemo.svelte @@ -0,0 +1,20 @@ + + +
+ +
+ + +
+ + + +
+ {#snippet footer()} + + {/snippet} +
diff --git a/apps/preview/src/demos/svelte/GridDemo.svelte b/apps/preview/src/demos/svelte/GridDemo.svelte new file mode 100644 index 0000000..6670bb0 --- /dev/null +++ b/apps/preview/src/demos/svelte/GridDemo.svelte @@ -0,0 +1,43 @@ + + +
+
+ {#each variants as v (v)} + + {/each} +
+ + {#if variant === "bento"} + + 2 × 2 + 2 × 1 + 1 + 1 + 3 × 1 + 1 + + {:else if variant === "auto-fit"} + + {#each Array(6) as _, i (i)}
min 140px · {i + 1}
{/each} +
+ {:else if variant === "columns"} + + {#each Array(6) as _, i (i)}
1 · 2 · 3 col · {i + 1}
{/each} +
+ {:else if variant === "masonry"} + + {#each heights as h, i (i)}
{i + 1}
{/each} +
+ {:else} + + +
Contenido
+
+ {/if} +
diff --git a/apps/preview/src/demos/svelte/ModalDemo.svelte b/apps/preview/src/demos/svelte/ModalDemo.svelte new file mode 100644 index 0000000..dace7da --- /dev/null +++ b/apps/preview/src/demos/svelte/ModalDemo.svelte @@ -0,0 +1,16 @@ + + +
+ +
+ + + + {#snippet footer()} + + + {/snippet} + diff --git a/apps/preview/src/demos/svelte/SelectDemo.svelte b/apps/preview/src/demos/svelte/SelectDemo.svelte new file mode 100644 index 0000000..b39f31c --- /dev/null +++ b/apps/preview/src/demos/svelte/SelectDemo.svelte @@ -0,0 +1,24 @@ + + +
+ +
diff --git a/apps/preview/src/demos/svelte/ToastDemo.svelte b/apps/preview/src/demos/svelte/ToastDemo.svelte new file mode 100644 index 0000000..1371981 --- /dev/null +++ b/apps/preview/src/demos/svelte/ToastDemo.svelte @@ -0,0 +1,12 @@ + + +
+ + + + +
+ + diff --git a/apps/preview/src/docs/i18n.svelte.ts b/apps/preview/src/docs/i18n.svelte.ts index ba48ff5..307d755 100644 --- a/apps/preview/src/docs/i18n.svelte.ts +++ b/apps/preview/src/docs/i18n.svelte.ts @@ -17,7 +17,7 @@ export function setLang(l: Lang) { const dict = { es: { getStarted: "Empezar", components: "Componentes", base: "Base", legal: "Legal", - groups: { IA: "IA", Formularios: "Formularios", Layout: "Layout", Feedback: "Feedback" }, + groups: { IA: "IA", Formularios: "Formularios", Layout: "Layout", Overlay: "Overlay", Feedback: "Feedback" }, guides: { introduccion: "Introducción", instalacion: "Instalación", tokens: "Tokens", licencia: "Licencia", acerca: "Acerca de" }, usage: "Uso", props: "Props", prop: "Prop", type: "Tipo", def: "Por defecto", desc: "Descripción", copy: "Copiar", copied: "Copiado", search: "Buscar…", searchLabel: "Buscar en la documentación", @@ -27,7 +27,7 @@ const dict = { }, en: { getStarted: "Get started", components: "Components", base: "Foundations", legal: "Legal", - groups: { IA: "AI", Formularios: "Forms", Layout: "Layout", Feedback: "Feedback" }, + groups: { IA: "AI", Formularios: "Forms", Layout: "Layout", Overlay: "Overlay", Feedback: "Feedback" }, guides: { introduccion: "Introduction", instalacion: "Installation", tokens: "Tokens", licencia: "License", acerca: "About" }, usage: "Usage", props: "Props", prop: "Prop", type: "Type", def: "Default", desc: "Description", copy: "Copy", copied: "Copied", search: "Search…", searchLabel: "Search documentation", @@ -61,6 +61,16 @@ export const en: Record