CD — Déploiement / deploy (push) Failing after 25s
- logo embarque dans les e-mails (CID) et gabarit repense en mode sombre - favicon multi-tailles + icone PNG, logo a gauche du titre (app et auth) - modale de confirmation animee a la place de window.confirm - bouton retour et fil d'ariane dans l'explorateur --------- Co-authored-by: xEsiah <[email protected]> Reviewed-on: #4 Reviewed-by: Esiah <[email protected]> Co-authored-by: Gitea Actions <-[email protected]>
73 lines
2.2 KiB
TypeScript
73 lines
2.2 KiB
TypeScript
import { useId } from "react";
|
|
import type { InputHTMLAttributes, ReactNode } from "react";
|
|
import { cn } from "../lib/cn.js";
|
|
|
|
export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size"> {
|
|
label?: ReactNode;
|
|
hint?: ReactNode;
|
|
error?: ReactNode;
|
|
sizeVariant?: "sm" | "md" | "lg";
|
|
}
|
|
|
|
const inputSize = {
|
|
sm: "h-8 px-2.5 text-xs",
|
|
md: "h-10 px-3 text-sm",
|
|
lg: "h-12 px-4 text-base",
|
|
} as const;
|
|
|
|
export const Input = ({
|
|
label,
|
|
hint,
|
|
error,
|
|
sizeVariant = "md",
|
|
id,
|
|
className,
|
|
disabled,
|
|
...props
|
|
}: InputProps) => {
|
|
const generatedId = useId();
|
|
const inputId = id ?? generatedId;
|
|
const messageId = `${inputId}-message`;
|
|
const isInvalid = error !== undefined && error !== null && error !== "";
|
|
|
|
return (
|
|
<div className="flex w-full flex-col gap-1.5">
|
|
{label ? (
|
|
<label
|
|
htmlFor={inputId}
|
|
className="font-display text-[0.6875rem] font-semibold uppercase tracking-label text-foreground"
|
|
>
|
|
{label}
|
|
</label>
|
|
) : null}
|
|
|
|
<input
|
|
id={inputId}
|
|
disabled={disabled}
|
|
aria-invalid={isInvalid}
|
|
aria-describedby={isInvalid || hint ? messageId : undefined}
|
|
className={cn(
|
|
"w-full rounded-sm border bg-surface text-foreground placeholder:text-subtle-foreground",
|
|
"transition-[background-color,border-color,box-shadow] duration-fast ease-out-soft",
|
|
"focus-visible:ring-ring focus-visible:border-border-strong focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:outline-none",
|
|
"disabled:cursor-not-allowed disabled:bg-surface-muted disabled:opacity-60",
|
|
isInvalid ? "border-destructive focus-visible:ring-destructive" : "border-border-control",
|
|
inputSize[sizeVariant],
|
|
className,
|
|
)}
|
|
{...props}
|
|
/>
|
|
|
|
{isInvalid || hint ? (
|
|
<p
|
|
id={messageId}
|
|
role={isInvalid ? "alert" : undefined}
|
|
className={cn("text-xs leading-relaxed", isInvalid ? "text-destructive" : "text-muted-foreground")}
|
|
>
|
|
{isInvalid ? error : hint}
|
|
</p>
|
|
) : null}
|
|
</div>
|
|
);
|
|
};
|