Skip to content

Commit 5a87f54

Browse files
authored
fix: color picker input hex values support (#56)
* hex color input
1 parent 25c55a1 commit 5a87f54

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

frontend/app/components/ColorPicker.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { ComponentPropsWithoutRef } from 'react'
22
import { forwardRef, useId, useState } from 'react'
3-
import { HexColorPicker } from 'react-colorful'
3+
import { HexColorPicker, HexColorInput } from 'react-colorful'
44
import { cx } from 'class-variance-authority'
55
import ClickAwayListener from 'react-click-away-listener'
66
import {
@@ -96,13 +96,23 @@ export const ColorPicker = forwardRef<HTMLDivElement, ColorPickerProps>(
9696
<div
9797
className={cx(
9898
'absolute border border-gray-400 p-1 -mt-8 ml-8 bg-gray-200 rounded-lg z-10',
99-
displayColorpicker ? 'flex' : 'hidden'
99+
displayColorpicker ? 'flex flex-col' : 'hidden'
100100
)}
101101
>
102+
<style>{`.react-colorful__last-control { border-radius: 0; }`}</style>
102103
<HexColorPicker
103104
color={String(value)}
104105
onChange={(color) => updateColor(color)}
105106
/>
107+
<div className="flex items-center justify-center p-2 bg-white border-t border-gray-300">
108+
<span className="text-gray-600 mr-2">#</span>
109+
<HexColorInput
110+
color={String(value)}
111+
onChange={(color) => updateColor(color)}
112+
className="w-24 px-2 py-1 text-sm border border-gray-300 rounded focus:outline-none focus:border-blue-500"
113+
placeholder="000000"
114+
/>
115+
</div>
106116
</div>
107117
</ClickAwayListener>
108118
</div>

0 commit comments

Comments
 (0)