feat: UI — home, new report form, editor with anatomy canvas + findings + PDF export

UI primitives (Tailwind, no shadcn CLI dependency):
- Button, Card, Input, Textarea, Label, Badge, Select, Dialog
- Brand, Header, Footer, Shell layout wrapper

Routes:
- HomeRoute: new bilan card + import PDF card with drag-drop, error toast
- NewReportRoute: 9-species selector (8 disabled badges 'à venir'),
  practitioner block (fullName required + title/phone/email/SIRET/address optional),
  animal+owner, sessionDate. Zod-validated form via react-hook-form
- EditorRoute: split view — anatomy canvas (3 tabs latéral L/R + dorsal) on the
  left, findings panel + conclusion + export button on the right
- NotFoundRoute

Editor:
- AnatomyView: fetch SVG, DOMParser-based (no innerHTML), click delegation on
  [data-zone], CSS-variable styling per state (default/selected/linked)
- AnatomyCanvas: animated tab switcher with motion shared layout
- ZoneSelection: chip bar of current selection, validate+reset buttons
- FindingEditor: modal dialog with severity radios, pathology multi-select
  filtered by zones, free-text pathology input, linked-zones picker, comment
- FindingPanel: list of findings with hover-preview wired to canvas highlight
- ConclusionPanel: conclusion + recommendations + next appointment
- ExportButton: triggers PDF download
- rasterize.ts: SVG → PNG bytes via canvas (used by editor before PDF export)

ESLint: relax strict-type-checked to React-idiomatic level (no-confusing-void-expression
off, no-misused-promises allows void-return attributes, no-floating-promises is warn).
2 remaining errors fixed (label a11y + optional chain in HomeRoute).

PDF export Blob: copy bytes into fresh ArrayBuffer before Blob ctor — TS strict
rejects ArrayBufferLike|SharedArrayBuffer as BlobPart in lib.dom 2026.

Tests: 34/34 still green. Build 5.6s (motion 96KB, pdf-lib 523KB chunks).
This commit is contained in:
ZenQuality committed 2026-05-17 07:18:13 +02:00
1 parent b5b2e163c9
commit f57d6ec3d3
27 files changed
+1574 -23

No files matched your search

+25 -2
View File
@@ -1,3 +1,26 @@
export function Brand() {
return null;
import { FR } from '@/i18n/fr';
export function Brand({ compact = false }: { compact?: boolean }) {
return (
<a href="/" className="inline-flex items-center gap-2 text-clinic-800 hover:text-clinic-900">
<svg
width={compact ? 24 : 32}
height={compact ? 24 : 32}
viewBox="0 0 64 64"
aria-hidden
>
<circle cx="32" cy="32" r="30" fill="currentColor" opacity="0.12" />
<circle cx="32" cy="32" r="22" fill="currentColor" opacity="0.18" />
<path
d="M22 28 Q32 18 42 28 Q42 38 32 46 Q22 38 22 28 Z"
fill="currentColor"
opacity="0.85"
/>
<circle cx="32" cy="34" r="3" fill="white" />
</svg>
<span className={compact ? 'font-display text-base' : 'font-display text-lg'}>
{FR.app.name}
</span>
</a>
);
}
+21 -1
View File
@@ -1,3 +1,23 @@
import { FR } from '@/i18n/fr';
export function Footer() {
return null;
const year = new Date().getFullYear();
return (
<footer className="border-t border-clinic-100 bg-white/60 px-6 py-4 text-xs text-clinic-700">
<div className="mx-auto flex max-w-7xl items-center justify-between">
<span>
{FR.app.name} · {year} ·{' '}
<a
href="https://www.gnu.org/licenses/agpl-3.0.html"
className="underline hover:text-clinic-900"
target="_blank"
rel="noreferrer"
>
AGPL-3.0
</a>
</span>
<span>{FR.app.tagline}</span>
</div>
</footer>
);
}
+9 -1
View File
@@ -1,3 +1,11 @@
import { Brand } from './Brand';
export function Header() {
return null;
return (
<header className="border-b border-clinic-100 bg-white/80 px-6 py-4 backdrop-blur">
<div className="mx-auto flex max-w-7xl items-center justify-between">
<Brand />
</div>
</header>
);
}
+14
View File
@@ -0,0 +1,14 @@
import type { ReactNode } from 'react';
import { Footer } from './Footer';
import { Header } from './Header';
export function Shell({ children }: { children: ReactNode }) {
return (
<div className="flex min-h-screen flex-col bg-surface text-ink">
<Header />
<main className="flex-1">{children}</main>
<Footer />
</div>
);
}
+33
View File
@@ -0,0 +1,33 @@
import type { HTMLAttributes, ReactNode } from 'react';
import { cn } from '@/lib/cn';
type Variant = 'neutral' | 'mild' | 'moderate' | 'severe' | 'soft';
const variants: Record<Variant, string> = {
neutral: 'bg-clinic-100 text-clinic-800',
mild: 'bg-clinic-200 text-clinic-800',
moderate: 'bg-warm-300 text-clinic-900',
severe: 'bg-warm-500 text-white',
soft: 'bg-clinic-50 text-clinic-700 border border-clinic-100',
};
export function Badge({
variant = 'neutral',
className,
children,
...rest
}: HTMLAttributes<HTMLSpanElement> & { variant?: Variant; children?: ReactNode }) {
return (
<span
className={cn(
'inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium',
variants[variant],
className,
)}
{...rest}
>
{children}
</span>
);
}
+45
View File
@@ -0,0 +1,45 @@
import type { ButtonHTMLAttributes, ReactNode } from 'react';
import { cn } from '@/lib/cn';
type Variant = 'primary' | 'secondary' | 'ghost' | 'danger';
type Size = 'sm' | 'md' | 'lg';
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
variant?: Variant;
size?: Size;
children?: ReactNode;
}
const base =
'inline-flex items-center justify-center gap-2 rounded-md font-medium transition-colors ' +
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-clinic-500 focus-visible:ring-offset-2 ' +
'disabled:pointer-events-none disabled:opacity-50';
const variants: Record<Variant, string> = {
primary: 'bg-clinic-600 text-white hover:bg-clinic-700',
secondary: 'bg-clinic-100 text-clinic-800 hover:bg-clinic-200',
ghost: 'text-clinic-700 hover:bg-clinic-100',
danger: 'bg-warm-500 text-white hover:bg-warm-400',
};
const sizes: Record<Size, string> = {
sm: 'h-8 px-3 text-sm',
md: 'h-10 px-4 text-sm',
lg: 'h-12 px-6 text-base',
};
export function Button({
variant = 'primary',
size = 'md',
className,
children,
type = 'button',
...rest
}: ButtonProps) {
return (
<button type={type} className={cn(base, variants[variant], sizes[size], className)} {...rest}>
{children}
</button>
);
}
+37
View File
@@ -0,0 +1,37 @@
import type { HTMLAttributes, ReactNode } from 'react';
import { cn } from '@/lib/cn';
export function Card({
className,
children,
...rest
}: HTMLAttributes<HTMLDivElement> & { children?: ReactNode }) {
return (
<div
className={cn(
'rounded-lg border border-clinic-100 bg-white shadow-sm',
className,
)}
{...rest}
>
{children}
</div>
);
}
export function CardHeader({
className,
children,
}: HTMLAttributes<HTMLDivElement> & { children?: ReactNode }) {
return (
<div className={cn('border-b border-clinic-100 p-5', className)}>{children}</div>
);
}
export function CardBody({
className,
children,
}: HTMLAttributes<HTMLDivElement> & { children?: ReactNode }) {
return <div className={cn('p-5', className)}>{children}</div>;
}
+58
View File
@@ -0,0 +1,58 @@
import { AnimatePresence, motion } from 'motion/react';
import type { ReactNode } from 'react';
import { useEffect } from 'react';
import { SPRING } from '@/lib/motion';
import { cn } from '@/lib/cn';
interface DialogProps {
open: boolean;
onClose: () => void;
title?: string;
children?: ReactNode;
className?: string;
}
export function Dialog({ open, onClose, title, children, className }: DialogProps) {
useEffect(() => {
if (!open) return undefined;
const onKey = (e: KeyboardEvent) => {
if (e.key === 'Escape') onClose();
};
document.addEventListener('keydown', onKey);
return () => document.removeEventListener('keydown', onKey);
}, [open, onClose]);
return (
<AnimatePresence>
{open && (
<div className="fixed inset-0 z-50 flex items-center justify-center">
<motion.div
className="absolute inset-0 bg-clinic-900/40"
onClick={onClose}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{ duration: 0.15 }}
/>
<motion.div
role="dialog"
aria-modal="true"
aria-label={title}
className={cn(
'relative z-10 max-h-[85vh] w-full max-w-3xl overflow-auto rounded-lg bg-white p-6 shadow-xl',
className,
)}
initial={{ opacity: 0, y: 12, scale: 0.98 }}
animate={{ opacity: 1, y: 0, scale: 1 }}
exit={{ opacity: 0, y: 6, scale: 0.98 }}
transition={SPRING}
>
{title && <h2 className="mb-4 font-display text-xl text-clinic-900">{title}</h2>}
{children}
</motion.div>
</div>
)}
</AnimatePresence>
);
}
+21
View File
@@ -0,0 +1,21 @@
import type { InputHTMLAttributes } from 'react';
import { forwardRef } from 'react';
import { cn } from '@/lib/cn';
export const Input = forwardRef<HTMLInputElement, InputHTMLAttributes<HTMLInputElement>>(
function Input({ className, ...rest }, ref) {
return (
<input
ref={ref}
className={cn(
'h-10 w-full rounded-md border border-clinic-200 bg-white px-3 text-sm',
'placeholder:text-clinic-400 focus:border-clinic-500 focus:outline-none focus:ring-1 focus:ring-clinic-500',
'disabled:bg-clinic-50 disabled:text-clinic-400',
className,
)}
{...rest}
/>
);
},
);
+15
View File
@@ -0,0 +1,15 @@
import type { LabelHTMLAttributes, ReactNode } from 'react';
import { cn } from '@/lib/cn';
export function Label({
className,
children,
...rest
}: LabelHTMLAttributes<HTMLLabelElement> & { children?: ReactNode }) {
return (
<label className={cn('mb-1.5 block text-sm font-medium text-clinic-800', className)} {...rest}>
{children}
</label>
);
}
+23
View File
@@ -0,0 +1,23 @@
import type { SelectHTMLAttributes } from 'react';
import { forwardRef } from 'react';
import { cn } from '@/lib/cn';
export const Select = forwardRef<HTMLSelectElement, SelectHTMLAttributes<HTMLSelectElement>>(
function Select({ className, children, ...rest }, ref) {
return (
<select
ref={ref}
className={cn(
'h-10 w-full rounded-md border border-clinic-200 bg-white px-3 text-sm',
'focus:border-clinic-500 focus:outline-none focus:ring-1 focus:ring-clinic-500',
'disabled:bg-clinic-50 disabled:text-clinic-400',
className,
)}
{...rest}
>
{children}
</select>
);
},
);
+21
View File
@@ -0,0 +1,21 @@
import type { TextareaHTMLAttributes } from 'react';
import { forwardRef } from 'react';
import { cn } from '@/lib/cn';
export const Textarea = forwardRef<
HTMLTextAreaElement,
TextareaHTMLAttributes<HTMLTextAreaElement>
>(function Textarea({ className, ...rest }, ref) {
return (
<textarea
ref={ref}
className={cn(
'min-h-[88px] w-full rounded-md border border-clinic-200 bg-white p-3 text-sm leading-relaxed',
'placeholder:text-clinic-400 focus:border-clinic-500 focus:outline-none focus:ring-1 focus:ring-clinic-500',
className,
)}
{...rest}
/>
);
});