Files
AgendaPro/src/components/ui.tsx
T
AgendaPro DevandClaude Opus 5 4c19244df9 feat: public landing page with magic login, brand palette and demo build flag
Adds a public funnel landing at `/` and moves the login to `/login`, rebuilt
around the panel's own colors instead of an invented palette.

Landing (`src/components/landing/`, one section per file, no props):
- Seven funnel sections composed by `LandingPage`. The hero's eight swatches are
  literally `PIE_COLORS` from `DashboardPage`, the same hex values the seed hands
  to avatars and services, so "your colors become your numbers" is literal.
- `BrandMark` becomes the single source for the logo, replicating
  `public/favicon.svg`. Blue is the action surface, orange only ever marks.
- `NotebookVisual` is the one deliberate exception to the palette: it is what the
  product replaces.
- Copy drops all system vocabulary; motion comes from `src/lib/motion.ts` with a
  single easing, and reduced-motion resolves `initial` to the final state so a
  never-firing `whileInView` cannot leave a section invisible forever.

Routing and bundle:
- `homePathFor` is the single definition of each role's destination.
- Landing, login, dashboard and calendar load lazily. Eager, the login dragged
  framer-motion (~40 KB gz) into every panel load and the landing downloaded
  recharts + FullCalendar (~187 KB gz) without charting anything. `clsx` is
  pinned to the `react` chunk because Rollup otherwise assigns it to `charts`,
  making the entry import 111 KB gz for a 200-byte utility.

Responsiveness (iPhone/iPad), verified with `npm run audit:responsive`:
- No touch form field below 16px, `dvh` height utilities, safe-area insets, and
  40px touch targets keyed off `pointer: coarse` rather than `sm:`.
- New `.ld-gutter`: `.safe-x` lives outside `@layer` and beats Tailwind's `px-*`,
  so it left the login's side padding at 0 on anything but an iPhone in
  landscape. No overflow check could see it — there was no overflow, just zero
  margin. The audit now guards it with a `gutter` check.
- `shell-height` no longer fires on pages that legitimately scroll; the static
  `raw-viewport-unit` scan covers those instead.

Production build:
- The Dockerfile now sets `VITE_DEMO_UI=1` as a build arg. `DEMO` is a build-time
  constant, so without it Vite eliminated the magic login and the "Ver como…"
  switcher: the deployed landing promised "no registration" and led to an empty
  form. Verified by building both ways and diffing the bundle.
- Service worker cache bumped to v2 so the orphaned pre-landing chunks get purged
  from returning visitors' caches.

Verified: typecheck clean; unit 39/39, e2e 33/33, admin 17/17, booking 12/12,
landing 13/13 (WebKit), PWA passed against the real production build.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
2026-07-28 14:25:58 -06:00

114 lines
3.0 KiB
TypeScript

import { Loader2 } from "lucide-react";
export function Spinner({ className = "" }: { className?: string }) {
return <Loader2 className={`h-4 w-4 animate-spin ${className}`} />;
}
/**
* Fallback de Suspense para las rutas que se cargan por demanda (calendario y
* tablero, que arrastran FullCalendar y recharts). Ocupa el alto disponible para
* que el shell no dé un salto de layout al resolverse el chunk.
*/
export function RouteSpinner() {
return (
<div className="flex flex-1 items-center justify-center py-16 text-slate-400">
<Loader2 className="h-6 w-6 animate-spin" />
</div>
);
}
export function EmptyState({
icon: Icon,
title,
description,
action,
}: {
icon?: React.ComponentType<{ className?: string }>;
title: string;
description?: string;
action?: React.ReactNode;
}) {
return (
<div className="flex flex-col items-center justify-center gap-3 px-6 py-12 text-center">
{Icon && (
<div className="flex h-12 w-12 items-center justify-center rounded-2xl bg-slate-100 text-slate-400">
<Icon className="h-6 w-6" />
</div>
)}
<div>
<div className="text-sm font-bold text-slate-900">{title}</div>
{description && <p className="mt-1 text-sm text-slate-500">{description}</p>}
</div>
{action}
</div>
);
}
export function PageHeader({
title,
subtitle,
actions,
}: {
title: string;
subtitle?: string;
actions?: React.ReactNode;
}) {
return (
<div className="flex shrink-0 flex-col gap-3 px-5 pt-5 sm:px-7 sm:pt-7 md:flex-row md:items-end md:justify-between">
<div>
<h1 className="text-xl font-extrabold tracking-tight text-slate-900 sm:text-2xl">{title}</h1>
{/* El subtítulo se oculta en teléfono: son 2 líneas de texto descriptivo
(~70px) que en una pantalla de 390px le hacen falta al contenido, y
en el calendario además describe gestos de ratón ("arrastra",
"redimensiona") que no aplican al tacto. */}
{subtitle && <p className="mt-1 hidden text-sm text-slate-500 sm:block">{subtitle}</p>}
</div>
{actions && <div className="flex flex-wrap items-center gap-2">{actions}</div>}
</div>
);
}
export function Badge({
children,
bg,
fg,
dot,
}: {
children: React.ReactNode;
bg?: string;
fg?: string;
dot?: string;
}) {
return (
<span className="chip" style={{ background: bg ?? "#f3f4f6", color: fg ?? "#374151" }}>
{dot && <span className="h-1.5 w-1.5 rounded-full" style={{ background: dot }} />}
{children}
</span>
);
}
export function Avatar({
name,
color,
size = 36,
}: {
name: string;
color?: string;
size?: number;
}) {
const init = name
.split(" ")
.filter(Boolean)
.slice(0, 2)
.map((p) => p[0]?.toUpperCase())
.join("");
return (
<div
className="flex shrink-0 items-center justify-center rounded-full text-xs font-bold text-white"
style={{ background: color ?? "#3b66ff", width: size, height: size, fontSize: size * 0.35 }}
>
{init}
</div>
);
}