-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Fix ColorPicker undo stack additions #494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@KARM99 is attempting to deploy a commit to the dottle's projects Team on Vercel. A member of the Team first needs to authorize it. |
87df48d
to
00074ad
Compare
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's unify and move this logic to a custom component that wraps ColorPicker from semi-ui
The component would roughly look like this
import { ColorPicker as SemiColorPicker } from "@douyinfe/semi-ui";
import { useState } from "react";
export default function ColorPicker({
children,
value,
onBlur,
onChange,
...props
}) {
const [pickedColor, setPickedColor] = useState(null);
const handleBlur = () => {
if (pickedColor) onBlur(pickedColor);
setPickedColor(null);
};
return (
<div onPointerUp={handleBlur} onBlur={handleBlur}>
<SemiColorPicker
{...props}
value={SemiColorPicker.colorStringToValue(value)}
onChange={({ hex: color }) => {
setPickedColor(color);
onChange(color);
}}
>
{children}
</SemiColorPicker>
</div>
);
}
And it would be consumed like this:
<ColorPicker
usePopover={true}
value={data.color}
onChange={(color) => updateArea(i, { color })}
onBlur={(color) => handleColorPickerBlur(color)}
>
<div
className="h-[32px] w-[32px] rounded-sm shrink-0"
style={{ backgroundColor: data.color }}
/>
</ColorPicker>
00074ad
to
865f4ab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
* Fix ColorPicker undo stack additions * make custom component ColorPicker
No description provided.