ldc-bien-etre-animal/resources/ts/front/Components/Layout/IconCircleButton.tsx
2026-08-20 16:39:37 +02:00

43 lines
1.1 KiB
TypeScript

import { type ReactNode } from "react";
import useDeviceType from "@/hooks/use-device-type";
interface IconCircleButtonProps {
icon: ReactNode;
onClick?: () => void;
variant?: "outline" | "filled";
ariaLabel: string;
outlineColor?: string;
filledColor?: string;
size?: number;
className?: string;
}
export default function IconCircleButton({
icon,
onClick,
variant = "outline",
ariaLabel,
outlineColor = "border-primary text-primary hover:bg-primary/10",
filledColor = "bg-primary text-white hover:bg-primary/90",
size,
className = "",
}: Readonly<IconCircleButtonProps>) {
const { isMobile } = useDeviceType();
const buttonSize = size ?? (isMobile ? 40 : 56);
const variantClasses =
variant === "filled" ? filledColor : `border-2 ${outlineColor}`;
return (
<button
type="button"
onClick={onClick}
aria-label={ariaLabel}
style={{ width: buttonSize, height: buttonSize }}
className={`flex cursor-pointer items-center justify-center rounded-full transition-colors ${variantClasses} ${className}`}
>
{icon}
</button>
);
}