2024-05-17 13:18:11 +00:00
|
|
|
import { ButtonBase } from "@mui/material";
|
|
|
|
import { startTransition, useRef } from "react";
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
color: string;
|
|
|
|
onChange: (color: string) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function CircleColorPicker({ color, onChange }: Props) {
|
|
|
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ButtonBase
|
|
|
|
onClick={() => inputRef.current?.click()}
|
|
|
|
sx={{
|
|
|
|
aspectRatio: 1,
|
|
|
|
height: "22px",
|
|
|
|
width: "22px",
|
2024-05-24 13:44:16 +00:00
|
|
|
minWidth: "22px",
|
2024-05-17 13:18:11 +00:00
|
|
|
borderRadius: "50%",
|
|
|
|
backgroundColor: color,
|
|
|
|
border: "1px solid #4D4D4D",
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<input
|
|
|
|
ref={inputRef}
|
|
|
|
type="color"
|
|
|
|
value={color}
|
|
|
|
onChange={(e) => {
|
|
|
|
startTransition(() => {
|
|
|
|
onChange(e.target.value);
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
style={{
|
|
|
|
opacity: 0,
|
|
|
|
cursor: "pointer",
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</ButtonBase>
|
|
|
|
);
|
|
|
|
}
|