2024-03-02 03:43:02 +03:00
|
|
|
import { IconType } from "react-icons";
|
|
|
|
|
import {
|
|
|
|
|
Tooltip,
|
|
|
|
|
TooltipContent,
|
|
|
|
|
TooltipTrigger,
|
|
|
|
|
} from "@/components/ui/tooltip";
|
|
|
|
|
import { isDesktop } from "react-device-detect";
|
|
|
|
|
|
|
|
|
|
const variants = {
|
|
|
|
|
primary: {
|
2024-03-03 06:59:50 +03:00
|
|
|
active: "font-bold text-white bg-selected rounded-lg",
|
|
|
|
|
inactive: "text-secondary-foreground bg-secondary rounded-lg",
|
2024-03-02 03:43:02 +03:00
|
|
|
},
|
2024-03-03 06:59:50 +03:00
|
|
|
overlay: {
|
|
|
|
|
active: "font-bold text-white bg-selected rounded-full",
|
2024-03-05 16:00:27 +03:00
|
|
|
inactive:
|
|
|
|
|
"text-primary-white rounded-full bg-gradient-to-br from-gray-400 to-gray-500 bg-gray-500",
|
2024-03-02 03:43:02 +03:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
type CameraFeatureToggleProps = {
|
|
|
|
|
className?: string;
|
2024-03-03 06:59:50 +03:00
|
|
|
variant?: "primary" | "overlay";
|
2024-03-02 03:43:02 +03:00
|
|
|
isActive: boolean;
|
|
|
|
|
Icon: IconType;
|
|
|
|
|
title: string;
|
|
|
|
|
onClick?: () => void;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default function CameraFeatureToggle({
|
|
|
|
|
className = "",
|
|
|
|
|
variant = "primary",
|
|
|
|
|
isActive,
|
|
|
|
|
Icon,
|
|
|
|
|
title,
|
|
|
|
|
onClick,
|
|
|
|
|
}: CameraFeatureToggleProps) {
|
|
|
|
|
const content = (
|
|
|
|
|
<div
|
|
|
|
|
onClick={onClick}
|
2024-03-03 06:59:50 +03:00
|
|
|
className={`${className} flex flex-col justify-center items-center ${
|
2024-03-02 03:43:02 +03:00
|
|
|
variants[variant][isActive ? "active" : "inactive"]
|
|
|
|
|
}`}
|
|
|
|
|
>
|
2024-04-02 21:22:09 +03:00
|
|
|
<Icon
|
|
|
|
|
className={`size-5 md:m-[6px] ${isActive ? "text-white" : "text-muted-foreground"}`}
|
|
|
|
|
/>
|
2024-03-02 03:43:02 +03:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (isDesktop) {
|
|
|
|
|
return (
|
|
|
|
|
<Tooltip>
|
|
|
|
|
<TooltipTrigger>{content}</TooltipTrigger>
|
|
|
|
|
<TooltipContent side="bottom">
|
|
|
|
|
<p>{title}</p>
|
|
|
|
|
</TooltipContent>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return content;
|
|
|
|
|
}
|