Nessun cambio di funzionalità: solo resa, accessibilità e correzioni al layout su iPhone. - Aggiunge `viewport-fit=cover`: senza, su iOS `env(safe-area-inset-*)` valeva 0 e il margine per la barra gesture già presente nella bottom nav non aveva effetto. Aggiunge il margine superiore su hero, PageHeader e header dello scout, che in modalità standalone finivano sotto il notch. - Attiva il tema scuro sulla preferenza di sistema e ne riscrive i valori: l'accento resta il rosso del brand (prima diventava grigio-blu) e i token semantici che mancavano ora ci sono. `theme-color` ha una tinta per tema. - Sposta il feedback dal rilascio alla pressione su Button, bottom nav e comandi principali; aggiunge l'anello di focus da tastiera in `@layer base`, che mancava su tutti i bottoni scritti a mano fuori da components/ui/. - Rende la bottom nav una superficie traslucida con sfumatura di scorrimento al posto della riga netta, alleggerisce il velo dei drawer e sostituisce l'alone rosso delle ombre con ombre neutre. - Introduce una scala tipografica in rem con crenatura e interlinea per taglia, al posto dei 109 `text-[Npx]` fissi che non scalavano con l'impostazione di testo del sistema. - Porta a 44px le aree di tocco dei comandi piccoli, mostra uno scheletro di pagina al posto della schermata bianca in home e profilo, conserva le dissolvenze con movimento ridotto e aggiunge il supporto a `prefers-reduced-transparency` e `prefers-contrast`. - Anima l'apertura delle sezioni a tendina con Radix Collapsible, già fra le dipendenze, al posto di un montaggio secco. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
52 lines
2.1 KiB
TypeScript
52 lines
2.1 KiB
TypeScript
import * as React from "react";
|
|
import { Slot } from "@radix-ui/react-slot";
|
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
const buttonVariants = cva(
|
|
// Il feedback vive sulla pressione, non sul rilascio: su touch `hover` non
|
|
// esiste e senza `active:` il bottone sembra morto finche' non alzi il dito.
|
|
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium cursor-pointer transition-[transform,background-color,color,border-color,box-shadow] duration-100 ease-out active:scale-[0.97] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 disabled:cursor-not-allowed disabled:active:scale-100 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
{
|
|
variants: {
|
|
variant: {
|
|
default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
|
destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
|
|
outline:
|
|
"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
|
|
secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
|
|
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
link: "text-primary underline-offset-4 hover:underline",
|
|
},
|
|
size: {
|
|
default: "h-9 px-4 py-2",
|
|
sm: "h-8 rounded-md px-3 text-xs",
|
|
lg: "h-10 rounded-md px-8",
|
|
icon: "h-9 w-9",
|
|
},
|
|
},
|
|
defaultVariants: {
|
|
variant: "default",
|
|
size: "default",
|
|
},
|
|
},
|
|
);
|
|
|
|
export interface ButtonProps
|
|
extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
asChild?: boolean;
|
|
}
|
|
|
|
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
const Comp = asChild ? Slot : "button";
|
|
return (
|
|
<Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />
|
|
);
|
|
},
|
|
);
|
|
Button.displayName = "Button";
|
|
|
|
export { Button, buttonVariants };
|