@r2digisolutions/components 0.25.20 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/WORKSPACE.md +48 -0
- package/dist/components/molecules/ActionRow/ActionRow.stories.js +9 -0
- package/dist/components/molecules/ActionRow/ActionRow.svelte +84 -0
- package/dist/components/molecules/ActionRow/ActionRow.svelte.d.ts +31 -0
- package/dist/components/molecules/ActionRow/ActionRowStory.svelte +36 -0
- package/dist/components/molecules/ActionRow/ActionRowStory.svelte.d.ts +18 -0
- package/dist/components/molecules/Card/Card.svelte +4 -0
- package/dist/components/molecules/Card/Card.svelte.d.ts +2 -0
- package/dist/components/molecules/EntityHero/EntityHero.stories.js +9 -0
- package/dist/components/molecules/EntityHero/EntityHero.svelte +162 -0
- package/dist/components/molecules/EntityHero/EntityHero.svelte.d.ts +37 -0
- package/dist/components/molecules/EntityHero/EntityHeroStory.svelte +28 -0
- package/dist/components/molecules/EntityHero/EntityHeroStory.svelte.d.ts +18 -0
- package/dist/components/molecules/OrgSwitcher/OrgSwitcher.svelte +68 -23
- package/dist/components/molecules/OrgSwitcher/OrgSwitcher.svelte.d.ts +12 -0
- package/dist/components/molecules/SectionNav/SectionNav.stories.d.ts +12 -0
- package/dist/components/molecules/SectionNav/SectionNav.stories.js +9 -0
- package/dist/components/molecules/SectionNav/SectionNav.svelte +139 -0
- package/dist/components/molecules/SectionNav/SectionNav.svelte.d.ts +41 -0
- package/dist/components/molecules/SectionNav/SectionNavStory.svelte +48 -0
- package/dist/components/molecules/SectionNav/SectionNavStory.svelte.d.ts +3 -0
- package/dist/components/molecules/StatCard/StatCard.svelte +51 -15
- package/dist/components/molecules/StatCard/StatCard.svelte.d.ts +13 -2
- package/dist/components/organisms/BottomNav/BottomNav.svelte +93 -53
- package/dist/components/organisms/BottomNav/BottomNav.svelte.d.ts +17 -2
- package/dist/components/organisms/NavRail/NavRail.svelte +106 -34
- package/dist/components/organisms/NavRail/NavRail.svelte.d.ts +12 -0
- package/dist/components/organisms/ProfilePicker/ProfilePicker.stories.d.ts +12 -0
- package/dist/components/organisms/ProfilePicker/ProfilePicker.stories.js +9 -0
- package/dist/components/organisms/ProfilePicker/ProfilePicker.svelte +183 -0
- package/dist/components/organisms/ProfilePicker/ProfilePicker.svelte.d.ts +37 -0
- package/dist/components/organisms/ProfilePicker/ProfilePickerStory.svelte +18 -0
- package/dist/components/organisms/ProfilePicker/ProfilePickerStory.svelte.d.ts +3 -0
- package/dist/components/organisms/WorkspaceShell/WorkspaceShell.stories.d.ts +12 -0
- package/dist/components/organisms/WorkspaceShell/WorkspaceShell.stories.js +9 -0
- package/dist/components/organisms/WorkspaceShell/WorkspaceShell.svelte +75 -0
- package/dist/components/organisms/WorkspaceShell/WorkspaceShell.svelte.d.ts +30 -0
- package/dist/components/organisms/WorkspaceShell/WorkspaceShellStory.svelte +71 -0
- package/dist/components/organisms/WorkspaceShell/WorkspaceShellStory.svelte.d.ts +3 -0
- package/dist/index.d.ts +11 -2
- package/dist/index.js +5 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -104,6 +104,10 @@ export default defineConfig({
|
|
|
104
104
|
- En `vite dev` no hace nada: se escanea todo.
|
|
105
105
|
- Si solo quieres los tokens sin escanear nada: `@import '@r2digisolutions/components/theme.css';`.
|
|
106
106
|
|
|
107
|
+
## Paneles (estética workspace)
|
|
108
|
+
|
|
109
|
+
Guía de estructura y estilo para paneles de gestión: [WORKSPACE.md](WORKSPACE.md).
|
|
110
|
+
|
|
107
111
|
## Tema: modo + paleta
|
|
108
112
|
|
|
109
113
|
Hay dos ejes independientes en `<html>`:
|
package/WORKSPACE.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Estética «workspace» (paneles y back-offices)
|
|
2
|
+
|
|
3
|
+
Guía para que todos los paneles (Evobusiness, Gestor, CRM, etc.) se vean y se usen igual.
|
|
4
|
+
Úsala siempre que montes un panel de gestión con varias secciones. La referencia visual es el panel de Evobusiness.
|
|
5
|
+
|
|
6
|
+
## Estructura
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
Escritorio (≥ lg) NavRail (solid, con etiquetas) | SectionNav | barra superior + contenido
|
|
10
|
+
Tablet (md) NavRail | barra superior + contenido
|
|
11
|
+
Móvil cabecera móvil / contenido / BottomNav con botón + central
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Todo se monta con `WorkspaceShell`, que solo coloca las piezas. Cada app pasa sus snippets:
|
|
15
|
+
|
|
16
|
+
| Zona | Componente | Notas |
|
|
17
|
+
| -------------- | --------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
18
|
+
| `rail` | `NavRail variant="solid" showLabels` | Máximo 5 o 6 secciones arriba. Admin y la cuenta van en `footerItems`. Los contadores van en `badge`. |
|
|
19
|
+
| `secondary` | `SectionNav` | Título y una línea de la sección. Arriba, el `OrgSwitcher` en `header`. Abajo, en `footer`, el progreso o un enlace público. |
|
|
20
|
+
| `topbar` | migas + buscador (`CommandPalette`, Ctrl K) + botón **Crear** + campana | Altura de unos 60px y fondo transparente con desenfoque. |
|
|
21
|
+
| `mobileHeader` | switcher compacto + lupa + campana, y las subsecciones como pestañas (`Tabs` o enlaces) | |
|
|
22
|
+
| `bottomNav` | `BottomNav variant="docked" fabShape="square" activeStyle="color"` con `href` e `iconComponent` | 4 secciones y un `primary: true` en el centro para «Crear». |
|
|
23
|
+
|
|
24
|
+
Varias cuentas o empresas: `OrgSwitcher` (con `title`, `subtitle`, `badge`, `createLabel` y `footerNote`) en escritorio, y `ProfilePicker` (pantalla tipo perfiles de Netflix) en móvil y al entrar si hay más de una.
|
|
25
|
+
|
|
26
|
+
## Portada de la sección «Inicio» (dashboard)
|
|
27
|
+
|
|
28
|
+
1. `EntityHero coverSize="md"`: portada, logo, nombre, badges de estado y acciones (Compartir, QR, Editar). Los botones de la portada (Cambiar portada, Ajustar encuadre) van en el snippet `coverActions`: salen al pasar el ratón y siempre en táctil.
|
|
29
|
+
2. Fila de 4 `StatCard` con `labelIcon`, `sparkline` y `delta` en `deltaStyle="pill"`. En el móvil, en una fila con scroll lateral.
|
|
30
|
+
3. **Bandeja** (lo que necesita respuesta) con `ActionRow`: un icono con el `tone` del tipo, el título, `meta` con la fecha y la acción principal a la derecha (Responder, Aceptar…). Todo en una `Card`, con `Tabs` para filtrar.
|
|
31
|
+
4. Columna derecha: agenda de hoy, un resumen del escaparate y las tareas pendientes.
|
|
32
|
+
|
|
33
|
+
## Reglas visuales
|
|
34
|
+
|
|
35
|
+
- **Color:** solo los tokens `brand-*`. Cada app los redefine en su `@theme` (Evobusiness usa el verde `#31855b` como `brand-500`). Nunca pongas colores fijos en los componentes. Ámbar para avisos, rojo solo para errores y para borrar.
|
|
36
|
+
- **Superficies:** fondo `bg-surface`, tarjetas `bg-surface-elevated` con `border-border`, `rounded-2xl` y `shadow-sm` como mucho.
|
|
37
|
+
- **Texto:** Inter. Títulos `font-bold tracking-tight`. Etiquetas de grupo en `text-[11px] uppercase tracking-wider text-muted`.
|
|
38
|
+
- **Contadores:** en la barra verde, píldora ámbar. En los menús claros, píldora `brand-600` si requiere acción y gris si solo informa.
|
|
39
|
+
- **Iconos:** Lucide, con `strokeWidth` 1.75–1.9 y un tamaño de 18–20px en los menús.
|
|
40
|
+
- **Densidad:** filas de menú con `py-2` y tarjetas con `p-4`/`p-5`. Separación entre bloques de `gap-4`.
|
|
41
|
+
|
|
42
|
+
## Reglas de uso (todas las apps)
|
|
43
|
+
|
|
44
|
+
- Nada de elementos nativos sueltos (`<button>`, `<select>`, `<input>`…) en las apps: usa siempre los de esta librería. Si falta algo, se crea aquí, con su story, y se publica.
|
|
45
|
+
- Para los estados vacíos, `EmptyState`.
|
|
46
|
+
- En los modales (`Dialog`), las acciones van en el footer.
|
|
47
|
+
- Cada guardado o error termina en un toast. Donde se pueda, autoguardado.
|
|
48
|
+
- Los componentes nuevos van en la carpeta de su nivel (`atoms`, `molecules`, `organisms` o `templates`), con `XStory.svelte` y `X.stories.ts`, y se exportan en `src/lib/index.ts`.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Component, Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
export type ActionRowIcon = Component<{
|
|
5
|
+
class?: string;
|
|
6
|
+
size?: number | string;
|
|
7
|
+
strokeWidth?: number | string;
|
|
8
|
+
}>;
|
|
9
|
+
|
|
10
|
+
export type ActionRowTone = 'brand' | 'info' | 'warning' | 'danger' | 'neutral';
|
|
11
|
+
|
|
12
|
+
interface ActionRowProps {
|
|
13
|
+
title: string;
|
|
14
|
+
/** Small text next to the title (time ago, stars…). */
|
|
15
|
+
meta?: string;
|
|
16
|
+
/** Second line, truncated to one line. */
|
|
17
|
+
description?: string;
|
|
18
|
+
icon?: ActionRowIcon;
|
|
19
|
+
/** Colour of the icon tile: what kind of item this is. */
|
|
20
|
+
tone?: ActionRowTone;
|
|
21
|
+
/** Makes the title area a link (the actions stay independent). */
|
|
22
|
+
href?: string;
|
|
23
|
+
/** Mark as unread / new. */
|
|
24
|
+
unread?: boolean;
|
|
25
|
+
/** Hide the top divider (first row of a list). */
|
|
26
|
+
first?: boolean;
|
|
27
|
+
class?: string;
|
|
28
|
+
/** Inline extra after the title (stars, chips). */
|
|
29
|
+
titleExtra?: Snippet;
|
|
30
|
+
/** Buttons on the right (Responder, Aceptar…). */
|
|
31
|
+
actions?: Snippet;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const {
|
|
35
|
+
title,
|
|
36
|
+
meta,
|
|
37
|
+
description,
|
|
38
|
+
icon: Icon,
|
|
39
|
+
tone = 'brand',
|
|
40
|
+
href,
|
|
41
|
+
unread = false,
|
|
42
|
+
first = false,
|
|
43
|
+
class: className = '',
|
|
44
|
+
titleExtra,
|
|
45
|
+
actions
|
|
46
|
+
}: ActionRowProps = $props();
|
|
47
|
+
|
|
48
|
+
const TONES: Record<ActionRowTone, string> = {
|
|
49
|
+
brand: 'bg-brand-500/12 text-brand-700 dark:text-brand-300',
|
|
50
|
+
info: 'bg-sky-500/12 text-sky-700 dark:text-sky-300',
|
|
51
|
+
warning: 'bg-amber-500/15 text-amber-700 dark:text-amber-300',
|
|
52
|
+
danger: 'bg-red-500/12 text-red-700 dark:text-red-300',
|
|
53
|
+
neutral: 'bg-surface-overlay text-secondary'
|
|
54
|
+
};
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
{#snippet body()}
|
|
58
|
+
<span class="gap-1.5 flex items-center">
|
|
59
|
+
{#if unread}<span class="h-2 w-2 bg-brand-500 shrink-0 rounded-full" aria-label="Nuevo"
|
|
60
|
+
></span>{/if}
|
|
61
|
+
<span class="text-sm font-semibold text-primary truncate">{title}</span>
|
|
62
|
+
{#if titleExtra}{@render titleExtra()}{/if}
|
|
63
|
+
{#if meta}<span class="text-xs text-muted shrink-0">· {meta}</span>{/if}
|
|
64
|
+
</span>
|
|
65
|
+
{#if description}<span class="text-muted block truncate text-[13px]">{description}</span>{/if}
|
|
66
|
+
{/snippet}
|
|
67
|
+
|
|
68
|
+
<div class={['gap-3 py-3 flex items-center', !first && 'border-border border-t', className]}>
|
|
69
|
+
{#if Icon}
|
|
70
|
+
<span class={['h-9 w-9 rounded-xl flex shrink-0 items-center justify-center', TONES[tone]]}>
|
|
71
|
+
<Icon class="h-[18px] w-[18px]" strokeWidth={1.9} />
|
|
72
|
+
</span>
|
|
73
|
+
{/if}
|
|
74
|
+
{#if href}
|
|
75
|
+
<a
|
|
76
|
+
{href}
|
|
77
|
+
class="min-w-0 rounded-lg focus-visible:ring-brand-500/30 flex-1 focus-visible:ring-2 focus-visible:outline-none"
|
|
78
|
+
>{@render body()}</a
|
|
79
|
+
>
|
|
80
|
+
{:else}
|
|
81
|
+
<div class="min-w-0 flex-1">{@render body()}</div>
|
|
82
|
+
{/if}
|
|
83
|
+
{#if actions}<div class="gap-2 flex shrink-0 items-center">{@render actions()}</div>{/if}
|
|
84
|
+
</div>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Component, Snippet } from 'svelte';
|
|
2
|
+
export type ActionRowIcon = Component<{
|
|
3
|
+
class?: string;
|
|
4
|
+
size?: number | string;
|
|
5
|
+
strokeWidth?: number | string;
|
|
6
|
+
}>;
|
|
7
|
+
export type ActionRowTone = 'brand' | 'info' | 'warning' | 'danger' | 'neutral';
|
|
8
|
+
interface ActionRowProps {
|
|
9
|
+
title: string;
|
|
10
|
+
/** Small text next to the title (time ago, stars…). */
|
|
11
|
+
meta?: string;
|
|
12
|
+
/** Second line, truncated to one line. */
|
|
13
|
+
description?: string;
|
|
14
|
+
icon?: ActionRowIcon;
|
|
15
|
+
/** Colour of the icon tile: what kind of item this is. */
|
|
16
|
+
tone?: ActionRowTone;
|
|
17
|
+
/** Makes the title area a link (the actions stay independent). */
|
|
18
|
+
href?: string;
|
|
19
|
+
/** Mark as unread / new. */
|
|
20
|
+
unread?: boolean;
|
|
21
|
+
/** Hide the top divider (first row of a list). */
|
|
22
|
+
first?: boolean;
|
|
23
|
+
class?: string;
|
|
24
|
+
/** Inline extra after the title (stars, chips). */
|
|
25
|
+
titleExtra?: Snippet;
|
|
26
|
+
/** Buttons on the right (Responder, Aceptar…). */
|
|
27
|
+
actions?: Snippet;
|
|
28
|
+
}
|
|
29
|
+
declare const ActionRow: Component<ActionRowProps, {}, "">;
|
|
30
|
+
type ActionRow = ReturnType<typeof ActionRow>;
|
|
31
|
+
export default ActionRow;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import ActionRow from './ActionRow.svelte';
|
|
3
|
+
import Button from '../../atoms/Button/Button.svelte';
|
|
4
|
+
import { Inbox, CalendarCheck, Star } from '@lucide/svelte';
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<div class="max-w-2xl rounded-2xl border-border bg-surface-elevated px-5 py-2 border">
|
|
8
|
+
<ActionRow
|
|
9
|
+
first
|
|
10
|
+
unread
|
|
11
|
+
title="María G."
|
|
12
|
+
meta="hace 12 min"
|
|
13
|
+
description="Presupuesto: comida de empresa, 25 personas"
|
|
14
|
+
icon={Inbox}
|
|
15
|
+
tone="info"
|
|
16
|
+
>
|
|
17
|
+
{#snippet actions()}<Button size="sm">Responder</Button>{/snippet}
|
|
18
|
+
</ActionRow>
|
|
19
|
+
<ActionRow
|
|
20
|
+
title="Javier L."
|
|
21
|
+
meta="hace 1 h"
|
|
22
|
+
description="Reserva terraza · sáb. 21:30 · 6 personas"
|
|
23
|
+
icon={CalendarCheck}
|
|
24
|
+
>
|
|
25
|
+
{#snippet actions()}<Button size="sm" variant="outline">Rechazar</Button><Button size="sm"
|
|
26
|
+
>Aceptar</Button
|
|
27
|
+
>{/snippet}
|
|
28
|
+
</ActionRow>
|
|
29
|
+
<ActionRow
|
|
30
|
+
title="Ana R."
|
|
31
|
+
meta="ayer"
|
|
32
|
+
description="“Las croquetas de puchero, de lo mejor de Madrid.”"
|
|
33
|
+
icon={Star}
|
|
34
|
+
tone="warning"
|
|
35
|
+
/>
|
|
36
|
+
</div>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const ActionRowStory: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type ActionRowStory = InstanceType<typeof ActionRowStory>;
|
|
18
|
+
export default ActionRowStory;
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
/** Soft tint behind header / footer chrome (DiffViewer-style). Default true. */
|
|
12
12
|
chrome?: boolean;
|
|
13
13
|
class?: string;
|
|
14
|
+
/** DOM id (anchor links such as #bandeja). */
|
|
15
|
+
id?: string;
|
|
14
16
|
header?: Snippet;
|
|
15
17
|
footer?: Snippet;
|
|
16
18
|
children?: Snippet;
|
|
@@ -23,6 +25,7 @@
|
|
|
23
25
|
hoverable = false,
|
|
24
26
|
chrome = true,
|
|
25
27
|
class: className = '',
|
|
28
|
+
id,
|
|
26
29
|
header,
|
|
27
30
|
footer,
|
|
28
31
|
children,
|
|
@@ -55,6 +58,7 @@
|
|
|
55
58
|
|
|
56
59
|
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
57
60
|
<div
|
|
61
|
+
{id}
|
|
58
62
|
class={[
|
|
59
63
|
'rounded-2xl flex flex-col overflow-hidden transition-[box-shadow,transform,border-color] duration-200',
|
|
60
64
|
variantClasses[variant],
|
|
@@ -8,6 +8,8 @@ interface CardProps {
|
|
|
8
8
|
/** Soft tint behind header / footer chrome (DiffViewer-style). Default true. */
|
|
9
9
|
chrome?: boolean;
|
|
10
10
|
class?: string;
|
|
11
|
+
/** DOM id (anchor links such as #bandeja). */
|
|
12
|
+
id?: string;
|
|
11
13
|
header?: Snippet;
|
|
12
14
|
footer?: Snippet;
|
|
13
15
|
children?: Snippet;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
export interface EntityHeroStat {
|
|
5
|
+
label: string;
|
|
6
|
+
value: string | number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface EntityHeroProps {
|
|
10
|
+
/** Name of the business, project, profile… */
|
|
11
|
+
title: string;
|
|
12
|
+
/** One line under the title (category · address…). */
|
|
13
|
+
subtitle?: string;
|
|
14
|
+
/** Cover image URL. Without it a soft brand gradient is drawn. */
|
|
15
|
+
cover?: string;
|
|
16
|
+
/** Avatar/logo image URL. */
|
|
17
|
+
avatar?: string;
|
|
18
|
+
/** Fallback text inside the avatar tile (defaults to the title initials). */
|
|
19
|
+
initials?: string;
|
|
20
|
+
/** Key numbers on the right (desktop) / under the title (mobile). */
|
|
21
|
+
stats?: EntityHeroStat[];
|
|
22
|
+
/** Hide the cover band (compact header). */
|
|
23
|
+
compact?: boolean;
|
|
24
|
+
/** Height of the cover band. */
|
|
25
|
+
coverSize?: 'sm' | 'md' | 'lg';
|
|
26
|
+
/** Extra CSS for the cover <img> (framing: object-position, scale…). */
|
|
27
|
+
coverStyle?: string;
|
|
28
|
+
/** Buttons over the cover, shown on hover/focus (always on touch): «Cambiar portada», «Ajustar»… */
|
|
29
|
+
coverActions?: Snippet;
|
|
30
|
+
class?: string;
|
|
31
|
+
/** Status badges next to the title. */
|
|
32
|
+
badges?: Snippet;
|
|
33
|
+
/** Extra content in the subtitle line (e.g. «Abierto ahora»). */
|
|
34
|
+
meta?: Snippet;
|
|
35
|
+
/** Buttons on the right (Share, QR, Edit…). */
|
|
36
|
+
actions?: Snippet;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const {
|
|
40
|
+
title,
|
|
41
|
+
subtitle,
|
|
42
|
+
cover,
|
|
43
|
+
avatar,
|
|
44
|
+
initials,
|
|
45
|
+
stats = [],
|
|
46
|
+
compact = false,
|
|
47
|
+
coverSize = 'sm',
|
|
48
|
+
coverStyle,
|
|
49
|
+
coverActions,
|
|
50
|
+
class: className = '',
|
|
51
|
+
badges,
|
|
52
|
+
meta,
|
|
53
|
+
actions
|
|
54
|
+
}: EntityHeroProps = $props();
|
|
55
|
+
|
|
56
|
+
const fallback = $derived(
|
|
57
|
+
initials ??
|
|
58
|
+
title
|
|
59
|
+
.split(/\s+/)
|
|
60
|
+
.filter(Boolean)
|
|
61
|
+
.slice(0, 2)
|
|
62
|
+
.map((w) => w[0]?.toUpperCase() ?? '')
|
|
63
|
+
.join('')
|
|
64
|
+
);
|
|
65
|
+
</script>
|
|
66
|
+
|
|
67
|
+
<section
|
|
68
|
+
class={[
|
|
69
|
+
'rounded-2xl border-border bg-surface-elevated shadow-sm overflow-hidden border',
|
|
70
|
+
className
|
|
71
|
+
]}
|
|
72
|
+
>
|
|
73
|
+
{#if !compact}
|
|
74
|
+
<div
|
|
75
|
+
class={[
|
|
76
|
+
'entity-hero-cover group/cover relative overflow-hidden',
|
|
77
|
+
{ sm: 'h-16 sm:h-20', md: 'h-28 sm:h-36', lg: 'h-36 sm:h-48' }[coverSize]
|
|
78
|
+
]}
|
|
79
|
+
>
|
|
80
|
+
{#if cover}<img
|
|
81
|
+
src={cover}
|
|
82
|
+
alt=""
|
|
83
|
+
class="inset-0 absolute h-full w-full object-cover"
|
|
84
|
+
style={coverStyle}
|
|
85
|
+
/>{/if}
|
|
86
|
+
{#if coverActions}
|
|
87
|
+
<div
|
|
88
|
+
class="right-3 top-3 gap-2 absolute flex opacity-100 transition-opacity duration-200 [@media(hover:hover)]:opacity-0 [@media(hover:hover)]:group-hover/cover:opacity-100 [@media(hover:hover)]:group-focus-within/cover:opacity-100"
|
|
89
|
+
>
|
|
90
|
+
{@render coverActions()}
|
|
91
|
+
</div>
|
|
92
|
+
{/if}
|
|
93
|
+
</div>
|
|
94
|
+
{/if}
|
|
95
|
+
<div
|
|
96
|
+
class={['gap-4 px-4 pb-4 sm:px-5 lg:flex-row lg:items-end flex flex-col', compact && 'pt-4']}
|
|
97
|
+
>
|
|
98
|
+
<div class="min-w-0 gap-4 flex flex-1 items-start">
|
|
99
|
+
<span
|
|
100
|
+
class={[
|
|
101
|
+
'rounded-2xl bg-brand-600 font-bold text-white flex shrink-0 items-center justify-center overflow-hidden',
|
|
102
|
+
compact
|
|
103
|
+
? 'h-12 w-12 text-base'
|
|
104
|
+
: 'relative z-10 -mt-8 border-surface-elevated text-xl shadow-md h-[4.25rem] w-[4.25rem] border-4'
|
|
105
|
+
]}
|
|
106
|
+
>
|
|
107
|
+
{#if avatar}<img
|
|
108
|
+
src={avatar}
|
|
109
|
+
alt=""
|
|
110
|
+
class="h-full w-full object-cover"
|
|
111
|
+
/>{:else}{fallback}{/if}
|
|
112
|
+
</span>
|
|
113
|
+
<div class={['min-w-0', !compact && 'pt-2.5']}>
|
|
114
|
+
<div class="gap-2 flex flex-wrap items-center">
|
|
115
|
+
<h1 class="text-xl font-bold tracking-tight text-primary truncate">{title}</h1>
|
|
116
|
+
{#if badges}{@render badges()}{/if}
|
|
117
|
+
</div>
|
|
118
|
+
{#if subtitle || meta}
|
|
119
|
+
<p class="mt-0.5 text-sm text-muted truncate">
|
|
120
|
+
{subtitle}{#if subtitle && meta}<span aria-hidden="true">
|
|
121
|
+
·
|
|
122
|
+
</span>{/if}{#if meta}{@render meta()}{/if}
|
|
123
|
+
</p>
|
|
124
|
+
{/if}
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
{#if stats.length}
|
|
128
|
+
<div class="lg:pb-1 flex shrink-0 overflow-x-auto">
|
|
129
|
+
{#each stats as stat, i (stat.label)}
|
|
130
|
+
<div
|
|
131
|
+
class={[
|
|
132
|
+
'px-4',
|
|
133
|
+
i === 0 ? 'pl-0 lg:border-l lg:border-border lg:pl-4' : 'border-border border-l'
|
|
134
|
+
]}
|
|
135
|
+
>
|
|
136
|
+
<p class="text-lg font-bold leading-tight tracking-tight text-primary">{stat.value}</p>
|
|
137
|
+
<p class="text-xs text-muted whitespace-nowrap">{stat.label}</p>
|
|
138
|
+
</div>
|
|
139
|
+
{/each}
|
|
140
|
+
</div>
|
|
141
|
+
{/if}
|
|
142
|
+
{#if actions}<div class="gap-2 lg:pb-1 flex shrink-0 flex-wrap">{@render actions()}</div>{/if}
|
|
143
|
+
</div>
|
|
144
|
+
</section>
|
|
145
|
+
|
|
146
|
+
<style>
|
|
147
|
+
.entity-hero-cover {
|
|
148
|
+
background-color: var(--color-brand-200);
|
|
149
|
+
background-image:
|
|
150
|
+
radial-gradient(
|
|
151
|
+
circle at 18% 30%,
|
|
152
|
+
color-mix(in oklab, #f0c98f 70%, transparent) 0,
|
|
153
|
+
transparent 42%
|
|
154
|
+
),
|
|
155
|
+
radial-gradient(
|
|
156
|
+
circle at 72% 60%,
|
|
157
|
+
color-mix(in oklab, var(--color-brand-300) 80%, transparent) 0,
|
|
158
|
+
transparent 48%
|
|
159
|
+
),
|
|
160
|
+
linear-gradient(120deg, #c9a77c, var(--color-brand-400) 58%, var(--color-brand-600));
|
|
161
|
+
}
|
|
162
|
+
</style>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export interface EntityHeroStat {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string | number;
|
|
5
|
+
}
|
|
6
|
+
interface EntityHeroProps {
|
|
7
|
+
/** Name of the business, project, profile… */
|
|
8
|
+
title: string;
|
|
9
|
+
/** One line under the title (category · address…). */
|
|
10
|
+
subtitle?: string;
|
|
11
|
+
/** Cover image URL. Without it a soft brand gradient is drawn. */
|
|
12
|
+
cover?: string;
|
|
13
|
+
/** Avatar/logo image URL. */
|
|
14
|
+
avatar?: string;
|
|
15
|
+
/** Fallback text inside the avatar tile (defaults to the title initials). */
|
|
16
|
+
initials?: string;
|
|
17
|
+
/** Key numbers on the right (desktop) / under the title (mobile). */
|
|
18
|
+
stats?: EntityHeroStat[];
|
|
19
|
+
/** Hide the cover band (compact header). */
|
|
20
|
+
compact?: boolean;
|
|
21
|
+
/** Height of the cover band. */
|
|
22
|
+
coverSize?: 'sm' | 'md' | 'lg';
|
|
23
|
+
/** Extra CSS for the cover <img> (framing: object-position, scale…). */
|
|
24
|
+
coverStyle?: string;
|
|
25
|
+
/** Buttons over the cover, shown on hover/focus (always on touch): «Cambiar portada», «Ajustar»… */
|
|
26
|
+
coverActions?: Snippet;
|
|
27
|
+
class?: string;
|
|
28
|
+
/** Status badges next to the title. */
|
|
29
|
+
badges?: Snippet;
|
|
30
|
+
/** Extra content in the subtitle line (e.g. «Abierto ahora»). */
|
|
31
|
+
meta?: Snippet;
|
|
32
|
+
/** Buttons on the right (Share, QR, Edit…). */
|
|
33
|
+
actions?: Snippet;
|
|
34
|
+
}
|
|
35
|
+
declare const EntityHero: import("svelte").Component<EntityHeroProps, {}, "">;
|
|
36
|
+
type EntityHero = ReturnType<typeof EntityHero>;
|
|
37
|
+
export default EntityHero;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import EntityHero from './EntityHero.svelte';
|
|
3
|
+
import Badge from '../../atoms/Badge/Badge.svelte';
|
|
4
|
+
import Button from '../../atoms/Button/Button.svelte';
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<div class="max-w-5xl p-6">
|
|
8
|
+
<EntityHero
|
|
9
|
+
title="Bar La Plaza"
|
|
10
|
+
coverSize="md"
|
|
11
|
+
subtitle="Tapas, raciones y terraza · Calle Mayor 12, Madrid"
|
|
12
|
+
stats={[
|
|
13
|
+
{ label: 'Visitas', value: '1.284' },
|
|
14
|
+
{ label: 'Solicitudes', value: 6 },
|
|
15
|
+
{ label: 'Reservas', value: 14 },
|
|
16
|
+
{ label: 'Valoración', value: '4,8 ★' }
|
|
17
|
+
]}
|
|
18
|
+
>
|
|
19
|
+
{#snippet coverActions()}<Button size="sm" variant="secondary">Cambiar portada</Button><Button
|
|
20
|
+
size="sm"
|
|
21
|
+
variant="secondary">Ajustar encuadre</Button
|
|
22
|
+
>{/snippet}
|
|
23
|
+
{#snippet badges()}<Badge variant="success" dot>Publicada</Badge><Badge variant="warning"
|
|
24
|
+
>Verificación pendiente</Badge
|
|
25
|
+
>{/snippet}
|
|
26
|
+
{#snippet actions()}<Button variant="outline" size="sm">Mi QR</Button>{/snippet}
|
|
27
|
+
</EntityHero>
|
|
28
|
+
</div>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const EntityHeroStory: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type EntityHeroStory = InstanceType<typeof EntityHeroStory>;
|
|
18
|
+
export default EntityHeroStory;
|