feat(app): animal screens, relation panels, animals on the client page

Routes /app/animals, new, :animalId, edit under one workspace gate; list with
species filter; form (D-R7, U3 birth, no default sex or role, optional first
client); page with current and former relations, end, dates, void; client page
links its animals, adds one pre-associated, links an existing one. Card now
passes aria-labelledby, which it silently dropped.
This commit is contained in:
bchanot committed 2026-10-26 17:11:28 +01:00
1 parent e22357630f
commit 930499cd25
36 files changed
+5579 -113

No files matched your search

+3 -1
View File
@@ -1,9 +1,11 @@
import type { ButtonHTMLAttributes, ReactNode } from 'react'
import type { ButtonHTMLAttributes, ReactNode, Ref } from 'react'
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
variant?: 'primary' | 'secondary' | 'ghost' | 'danger'
size?: 'sm' | 'md' | 'lg'
children?: ReactNode
/** React 19 passes it as a prop; it reaches the <button> with the rest. */
ref?: Ref<HTMLButtonElement>
}
const VARIANTS: Record<NonNullable<ButtonProps['variant']>, string> = {
+4
View File
@@ -4,15 +4,19 @@ export interface CardProps {
children: ReactNode
className?: string
as?: 'div' | 'section' | 'article'
/** Names a section card by its heading, so it reads as a named region. */
'aria-labelledby'?: string
}
export default function Card({
children,
className = '',
as: Tag = 'div',
'aria-labelledby': labelledBy,
}: CardProps) {
return (
<Tag
aria-labelledby={labelledBy}
className={[
'rounded-2xl border border-[var(--color-border)] bg-[var(--color-surface)] shadow-sm',
className,
@@ -0,0 +1,86 @@
export interface ChoiceRadiosProps<V extends string> {
/** Prefix of the radio ids: the first one is `${id}-${options[0].value}`. */
id: string
legend: string
/** « obligatoire » or « facultatif », shown beside the legend like FormField. */
marker?: string
options: readonly { value: V; label: string }[]
/** '' when nothing is chosen: no option is preselected. */
value: V | ''
onChange: (value: V) => void
hint?: string
error?: string
}
/** The id of the radio that takes focus when the group is in error. */
export const firstChoiceId = (id: string, first: string) => `${id}-${first}`
/**
* A required choice among a few explicit options, as large touch targets
* (the client kind's look): a fieldset named by its legend, the error under
* it and linked from every radio, nothing checked until the user picks.
*/
export default function ChoiceRadios<V extends string>({
id,
legend,
marker,
options,
value,
onChange,
hint,
error,
}: ChoiceRadiosProps<V>) {
const describedBy = error ? `${id}-error` : hint ? `${id}-hint` : undefined
return (
<fieldset className="space-y-2">
{/* The look of Label (FormField), on the element that names the group. */}
<legend className="mb-1 flex w-full items-baseline justify-between text-sm font-medium text-[var(--color-ink)]">
<span>{legend}</span>
{marker && (
<span className="text-xs font-normal text-[var(--color-ink-muted)]">
{marker}
</span>
)}
</legend>
<div className="grid grid-cols-1 gap-2 min-[400px]:grid-cols-3">
{options.map((option) => (
<label
key={option.value}
className="flex min-h-11 cursor-pointer items-center gap-2 rounded-lg border border-[var(--color-border)] bg-white px-4 text-sm text-[var(--color-ink)] has-[:checked]:border-[var(--color-accent)] has-[:checked]:bg-[var(--color-accent)]/10 has-[:checked]:font-medium has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-[var(--color-accent)]"
>
<input
id={`${id}-${option.value}`}
type="radio"
name={id}
value={option.value}
checked={value === option.value}
onChange={() => onChange(option.value)}
aria-invalid={Boolean(error)}
aria-describedby={describedBy}
className="h-4 w-4 accent-[var(--color-accent)]"
/>
{option.label}
</label>
))}
</div>
{error ? (
<p
id={`${id}-error`}
role="alert"
className="text-sm text-[var(--color-danger)]"
>
{error}
</p>
) : (
hint && (
<p
id={`${id}-hint`}
className="text-xs text-[var(--color-ink-muted)]"
>
{hint}
</p>
)
)}
</fieldset>
)
}
+2
View File
@@ -6,6 +6,7 @@ export type IconName =
| 'dashboard'
| 'user'
| 'users'
| 'paw'
| 'tool'
| 'logout'
| 'eye'
@@ -22,6 +23,7 @@ const PATHS: Record<IconName, string> = {
dashboard: 'M4 4h7v7H4zM13 4h7v4h-7zM13 11h7v9h-7zM4 14h7v6H4z',
user: 'M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM4 21a8 8 0 0 1 16 0',
users: 'M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM2 21a7 7 0 0 1 14 0M16 3.5a4 4 0 0 1 0 7M22 21a7 7 0 0 0-4.5-6.5',
paw: 'M3.7 10.5a1.8 1.8 0 1 0 3.6 0 1.8 1.8 0 1 0-3.6 0M7.1 6.5a1.9 1.9 0 1 0 3.8 0 1.9 1.9 0 1 0-3.8 0M13.1 6.5a1.9 1.9 0 1 0 3.8 0 1.9 1.9 0 1 0-3.8 0M16.7 10.5a1.8 1.8 0 1 0 3.6 0 1.8 1.8 0 1 0-3.6 0M12 12.5c-2.5 0-5 3.2-5 5.3 0 1.6 1.3 2.4 2.8 2.4 1 0 1.5-.5 2.2-.5s1.2.5 2.2.5c1.5 0 2.8-.8 2.8-2.4 0-2.1-2.5-5.3-5-5.3z',
tool: 'M14 3l7 7-4 4-7-7zM10 10l-6 6 4 4 6-6M3 21l3-3',
logout: 'M10 4H5v16h5M15 8l5 4-5 4M20 12H9',
eye: 'M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12zM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z',