feat: logo et favicon, confirmation modale, fil d'ariane, e-mails sombres (#4)
CD — Déploiement / deploy (push) Failing after 25s
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]>
This commit was merged in pull request #4.
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
import type { ButtonHTMLAttributes, ReactNode } from "react";
|
||||
import { cn } from "../lib/cn.js";
|
||||
import { Spinner } from "./Spinner.js";
|
||||
import type { SpinnerSize } from "./Spinner.js";
|
||||
|
||||
const variantClasses = {
|
||||
primary: "bg-primary text-primary-foreground hover:bg-primary-hover",
|
||||
secondary: "border border-border-strong bg-surface text-foreground hover:bg-surface-hover",
|
||||
ghost: "text-foreground hover:bg-surface-hover",
|
||||
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive-hover",
|
||||
} as const;
|
||||
|
||||
const sizeClasses = {
|
||||
sm: "h-8 gap-1.5 rounded-sm px-3 text-[0.6875rem]",
|
||||
md: "h-10 gap-2 rounded-md px-4 text-xs",
|
||||
lg: "h-12 gap-2.5 rounded-lg px-6 text-sm",
|
||||
} as const;
|
||||
|
||||
const spinnerBySize: Record<keyof typeof sizeClasses, SpinnerSize> = {
|
||||
sm: "xs",
|
||||
md: "sm",
|
||||
lg: "md",
|
||||
};
|
||||
|
||||
export type ButtonVariant = keyof typeof variantClasses;
|
||||
export type ButtonSize = keyof typeof sizeClasses;
|
||||
|
||||
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
||||
variant?: ButtonVariant;
|
||||
size?: ButtonSize;
|
||||
isLoading?: boolean;
|
||||
showTextWhileLoading?: boolean;
|
||||
iconLeading?: ReactNode;
|
||||
iconTrailing?: ReactNode;
|
||||
fullWidth?: boolean;
|
||||
}
|
||||
|
||||
export const Button = ({
|
||||
variant = "primary",
|
||||
size = "md",
|
||||
isLoading = false,
|
||||
showTextWhileLoading = true,
|
||||
iconLeading,
|
||||
iconTrailing,
|
||||
fullWidth = false,
|
||||
disabled,
|
||||
type = "button",
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}: ButtonProps) => (
|
||||
<button
|
||||
type={type}
|
||||
disabled={disabled === true || isLoading}
|
||||
aria-busy={isLoading}
|
||||
className={cn(
|
||||
"inline-flex select-none items-center justify-center whitespace-nowrap font-display font-semibold uppercase tracking-label",
|
||||
"focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
||||
"transition-[background-color,border-color,color,box-shadow,opacity]",
|
||||
"disabled:pointer-events-none disabled:opacity-50",
|
||||
variantClasses[variant],
|
||||
sizeClasses[size],
|
||||
fullWidth && "w-full",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{isLoading ? <Spinner size={spinnerBySize[size]} /> : iconLeading}
|
||||
{isLoading && !showTextWhileLoading ? null : children}
|
||||
{isLoading ? null : iconTrailing}
|
||||
</button>
|
||||
);
|
||||
@@ -0,0 +1,49 @@
|
||||
import type { HTMLAttributes } from "react";
|
||||
import { cn } from "../lib/cn.js";
|
||||
|
||||
export const Card = ({ className, ...props }: HTMLAttributes<HTMLDivElement>) => (
|
||||
<div
|
||||
className={cn(
|
||||
"relative overflow-hidden rounded-lg border border-border bg-surface text-foreground shadow-sm",
|
||||
"transition-colors duration-base ease-out-soft",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
|
||||
/* Signature du produit : un filet carmin d'un pixel en tete de carte. Invisible sur
|
||||
une grille dense, mais c'est lui qui donne aux cartes leur epaisseur et evite
|
||||
l'aspect de tuiles interchangeables. */
|
||||
export const CardHeader = ({ className, ...props }: HTMLAttributes<HTMLDivElement>) => (
|
||||
<div
|
||||
className={cn(
|
||||
"relative flex flex-col gap-1.5 p-5",
|
||||
"before:absolute before:inset-x-0 before:top-0 before:h-px before:bg-accent-graphic",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
|
||||
export const CardTitle = ({ className, ...props }: HTMLAttributes<HTMLHeadingElement>) => (
|
||||
<h3
|
||||
className={cn(
|
||||
"font-display text-sm font-semibold uppercase leading-tight tracking-label",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
|
||||
export const CardDescription = ({ className, ...props }: HTMLAttributes<HTMLParagraphElement>) => (
|
||||
<p className={cn("text-sm leading-relaxed text-muted-foreground", className)} {...props} />
|
||||
);
|
||||
|
||||
export const CardContent = ({ className, ...props }: HTMLAttributes<HTMLDivElement>) => (
|
||||
<div className={cn("p-5 pt-0", className)} {...props} />
|
||||
);
|
||||
|
||||
export const CardFooter = ({ className, ...props }: HTMLAttributes<HTMLDivElement>) => (
|
||||
<div className={cn("flex items-center gap-2 p-5 pt-0", className)} {...props} />
|
||||
);
|
||||
@@ -0,0 +1,72 @@
|
||||
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>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
import type { HTMLAttributes } from "react";
|
||||
import { cn } from "../lib/cn.js";
|
||||
|
||||
export type SkeletonProps = HTMLAttributes<HTMLDivElement> & {
|
||||
width?: string;
|
||||
height?: string;
|
||||
radius?: "sm" | "md" | "lg" | "xl" | "full";
|
||||
};
|
||||
|
||||
const skeletonRadius = {
|
||||
sm: "rounded-sm",
|
||||
md: "rounded-md",
|
||||
lg: "rounded-lg",
|
||||
xl: "rounded-xl",
|
||||
full: "rounded-full",
|
||||
} as const;
|
||||
|
||||
export const Skeleton = ({
|
||||
width,
|
||||
height,
|
||||
radius = "md",
|
||||
className,
|
||||
style,
|
||||
...props
|
||||
}: SkeletonProps) => (
|
||||
<div
|
||||
aria-hidden="true"
|
||||
style={{ width, height, ...style }}
|
||||
className={cn("animate-pulse bg-skeleton-base motion-reduce:animate-none", skeletonRadius[radius], className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
@@ -0,0 +1,36 @@
|
||||
import type { SVGProps } from "react";
|
||||
import { cn } from "../lib/cn.js";
|
||||
|
||||
const spinnerSize = {
|
||||
xs: "size-3",
|
||||
sm: "size-3.5",
|
||||
md: "size-4",
|
||||
lg: "size-4.5",
|
||||
} as const;
|
||||
|
||||
export type SpinnerSize = keyof typeof spinnerSize;
|
||||
|
||||
export interface SpinnerProps extends Omit<SVGProps<SVGSVGElement>, "children"> {
|
||||
size?: SpinnerSize;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
export const Spinner = ({ size = "md", label, className, ...props }: SpinnerProps) => (
|
||||
<svg
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
role={label ? "status" : undefined}
|
||||
aria-label={label}
|
||||
aria-hidden={label ? undefined : true}
|
||||
className={cn("shrink-0 animate-spin motion-reduce:animate-none", spinnerSize[size], className)}
|
||||
{...props}
|
||||
>
|
||||
<circle cx="12" cy="12" r="9" stroke="currentColor" strokeWidth="2.5" opacity="0.25" />
|
||||
<path
|
||||
d="M21 12a9 9 0 0 0-9-9"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2.5"
|
||||
strokeLinecap="round"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
@@ -0,0 +1,10 @@
|
||||
export { cn } from "./lib/cn.js";
|
||||
export type { SpinnerProps, SpinnerSize } from "./components/Spinner.js";
|
||||
export { Spinner } from "./components/Spinner.js";
|
||||
export type { ButtonProps, ButtonSize, ButtonVariant } from "./components/Button.js";
|
||||
export { Button } from "./components/Button.js";
|
||||
export type { SkeletonProps } from "./components/Skeleton.js";
|
||||
export { Skeleton } from "./components/Skeleton.js";
|
||||
export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "./components/Card.js";
|
||||
export type { InputProps } from "./components/Input.js";
|
||||
export { Input } from "./components/Input.js";
|
||||
@@ -0,0 +1,5 @@
|
||||
import { clsx } from "clsx";
|
||||
import type { ClassValue } from "clsx";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
export const cn = (...inputs: ClassValue[]): string => twMerge(clsx(inputs));
|
||||
Reference in New Issue
Block a user