Skip to content

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

Merged
merged 2 commits into from
Jun 20, 2025

Conversation

KARM99
Copy link
Contributor

@KARM99 KARM99 commented Jun 14, 2025

No description provided.

Copy link

vercel bot commented Jun 14, 2025

@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.

@KARM99 KARM99 force-pushed the fix-colorpicker-undo-stack branch 2 times, most recently from 87df48d to 00074ad Compare June 14, 2025 08:16
Copy link

vercel bot commented Jun 14, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
drawdb ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 19, 2025 5:56pm

Copy link
Member

@1ilit 1ilit left a 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>

Copy link
Member

@1ilit 1ilit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@1ilit 1ilit merged commit e56f640 into drawdb-io:main Jun 20, 2025
4 checks passed
@KARM99 KARM99 deleted the fix-colorpicker-undo-stack branch June 20, 2025 20:12
ewqazxc pushed a commit to ewqazxc/drawdb that referenced this pull request Jun 23, 2025
* Fix ColorPicker undo stack additions

* make custom component ColorPicker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants