-
-
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
base: main
Are you sure you want to change the base?
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. |
8e0a89c
to
87df48d
Compare
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>
@@ -217,10 +217,32 @@ export default function Area({ | |||
|
|||
function EditPopoverContent({ data }) { | |||
const [editField, setEditField] = useState({}); | |||
const [pickedColor, setPickedColor] = useState(undefined); |
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.
const [pickedColor, setPickedColor] = useState(undefined); | |
const [pickedColor, setPickedColor] = useState(null); |
const { updateArea, deleteArea } = useAreas(); | ||
const { setUndoStack, setRedoStack } = useUndoRedo(); | ||
const { t } = useTranslation(); | ||
|
||
const handleColorPickerChange = () => { |
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.
const handleColorPickerChange = () => { | |
const handleColorPickerBlur = () => { |
}, | ||
]); | ||
setRedoStack([]); | ||
setPickedColor(undefined); |
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.
setPickedColor(undefined); | |
setPickedColor(null); |
const { updateArea, deleteArea } = useAreas(); | ||
const { setUndoStack, setRedoStack } = useUndoRedo(); | ||
const { t } = useTranslation(); | ||
|
||
const handleColorPickerChange = () => { | ||
if (pickedColor !== undefined) { |
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.
if (pickedColor !== undefined) { | |
if (pickedColor) { |
usePopover={true} | ||
value={ColorPicker.colorStringToValue(data.color)} | ||
> | ||
<div |
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.
Format please
No description provided.