-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
62fe0c7
commit a78ee79
Showing
4 changed files
with
425 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"use client" | ||
|
||
import { PopoverContent } from "@radix-ui/react-popover" | ||
import { | ||
hslaToHsva, | ||
hsvaToHex, | ||
type ColorResult, | ||
type HslColor, | ||
} from "@uiw/react-color" | ||
import ChromeColorPicker from "@uiw/react-color-chrome" | ||
import { Popover, PopoverTrigger } from "../popover" | ||
|
||
export const ColorPicker = ({ | ||
disabled, | ||
color, | ||
onColorChange, | ||
}: { | ||
disabled?: boolean | ||
color: HslColor | ||
onColorChange: (color: ColorResult) => void | ||
}) => { | ||
const hsva = hslaToHsva({ ...color, a: 1 }) | ||
|
||
return ( | ||
<Popover> | ||
<PopoverTrigger disabled={disabled} asChild> | ||
<button | ||
className="my-1 size-6 flex-shrink-0 rounded border" | ||
style={{ backgroundColor: hsvaToHex(hsva) }} | ||
/> | ||
</PopoverTrigger> | ||
<PopoverContent className="isolate z-50"> | ||
<ChromeColorPicker | ||
color={hsva} | ||
onChange={onColorChange} | ||
showHue={true} | ||
showColorPreview={true} | ||
/> | ||
</PopoverContent> | ||
</Popover> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.