Files
CoHaiSe-CLOUD/frontend/src/components/IconAction.tsx
T
Gitea ActionsandEsiah 82cd712252
CD — Deployment / deploy (push) Successful in 33s
feat(ui): glass layout, icon actions and new icon set (#21)
PR automatique de feat/ui-glass-layout-icons vers main.

---------

Co-authored-by: xEsiah <[email protected]>
Reviewed-on: #21
Reviewed-by: Esiah <[email protected]>
Co-authored-by: Gitea Actions <-[email protected]>
2026-11-03 22:37:34 +00:00

42 lines
1.3 KiB
TypeScript

import type { ReactNode } from "react";
import { Spinner, cn } from "../ui/index.js";
export const IconAction = ({
label,
icon,
onClick,
isLoading = false,
tone = "neutral",
badge = 0,
}: {
label: string;
icon: ReactNode;
onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
isLoading?: boolean;
tone?: "neutral" | "danger";
badge?: number;
}) => (
<button
type="button"
title={label}
aria-label={label}
disabled={isLoading}
onClick={onClick}
className={cn(
"group relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-all",
"hover:-translate-y-0.5 hover:bg-surface/60 hover:text-foreground hover:shadow-sm backdrop-blur-sm disabled:pointer-events-none disabled:opacity-50",
tone === "danger" && "hover:text-destructive",
)}
>
{isLoading ? <Spinner size="xs" /> : icon}
{badge > 0 ? (
<span
aria-hidden="true"
className="pointer-events-none absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full bg-accent-graphic px-1 font-display text-[0.625rem] font-semibold leading-none text-accent-foreground"
>
{badge > 99 ? "99+" : badge}
</span>
) : null}
</button>
);