2023-05-15 14:18:33 -05:00
|
|
|
import { faSquare, faSquareCheck } from "@fortawesome/free-regular-svg-icons";
|
|
|
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
|
|
import { ChangeEventHandler } from "react";
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
label: string;
|
|
|
|
state: boolean;
|
2023-05-18 13:02:17 -05:00
|
|
|
className?: string;
|
2023-05-15 14:18:33 -05:00
|
|
|
onClick: ChangeEventHandler<HTMLInputElement>;
|
|
|
|
};
|
|
|
|
|
2023-05-18 13:02:17 -05:00
|
|
|
export default function Checkbox({ label, state, className, onClick }: Props) {
|
2023-05-15 14:18:33 -05:00
|
|
|
return (
|
2023-05-18 13:02:17 -05:00
|
|
|
<label
|
2023-07-22 16:49:09 -05:00
|
|
|
className={`cursor-pointer flex items-center gap-2 text-sky-700 ${className}`}
|
2023-05-18 13:02:17 -05:00
|
|
|
>
|
2023-05-15 14:18:33 -05:00
|
|
|
<input
|
|
|
|
type="checkbox"
|
|
|
|
checked={state}
|
|
|
|
onChange={onClick}
|
|
|
|
className="peer sr-only"
|
|
|
|
/>
|
|
|
|
<FontAwesomeIcon
|
|
|
|
icon={faSquareCheck}
|
2023-07-22 16:49:09 -05:00
|
|
|
className="w-5 h-5 text-sky-700 peer-checked:block hidden"
|
2023-05-15 14:18:33 -05:00
|
|
|
/>
|
|
|
|
<FontAwesomeIcon
|
|
|
|
icon={faSquare}
|
2023-07-22 16:49:09 -05:00
|
|
|
className="w-5 h-5 text-sky-700 peer-checked:hidden block"
|
2023-05-15 14:18:33 -05:00
|
|
|
/>
|
|
|
|
<span className="text-sky-900 rounded select-none">{label}</span>
|
|
|
|
</label>
|
|
|
|
);
|
|
|
|
}
|