11import { createSignal , onCleanup , onMount , Show , type Component } from "solid-js" ;
22import { IME_COMPOSING_KEY_CODE } from "../../constants.js" ;
3+ import { formatColorLabel } from "../../utils/format-color-label.js" ;
34import { parseAnyColor } from "../../utils/parse-any-color.js" ;
45import { EDIT_LABEL_CLASS } from "./constants.js" ;
56
@@ -19,11 +20,12 @@ interface ColorPickerProps {
1920 emphasized ?: boolean ;
2021}
2122
22- const HEX_CLASS = "text-[12px] leading-4 font-medium tabular-nums uppercase " ;
23+ const HEX_CLASS = "text-[12px] leading-4 font-medium tabular-nums" ;
2324
2425export const ColorPicker : Component < ColorPickerProps > = ( props ) => {
2526 const [ draftText , setDraftText ] = createSignal < string | null > ( null ) ;
2627 const isEditing = ( ) => draftText ( ) !== null ;
28+ const displayValue = ( ) => formatColorLabel ( props . value ) ;
2729 let nativePickerRef : HTMLInputElement | undefined ;
2830
2931 // isMounted gates the native picker's `onInput` against firing
@@ -97,14 +99,15 @@ export const ColorPicker: Component<ColorPickerProps> = (props) => {
9799 fallback = {
98100 < span
99101 class = { `${ HEX_CLASS } text-[var(--rg-text-primary)] cursor-text` }
102+ data-react-grab-value = { displayValue ( ) }
100103 onPointerDown = { ( event ) => event . stopPropagation ( ) }
101104 onClick = { ( event ) => {
102105 event . preventDefault ( ) ;
103106 event . stopPropagation ( ) ;
104- setDraftText ( props . value . replace ( / ^ # / , "" ) . toUpperCase ( ) ) ;
107+ setDraftText ( displayValue ( ) ) ;
105108 } }
106109 >
107- { props . value . toUpperCase ( ) }
110+ { displayValue ( ) }
108111 </ span >
109112 }
110113 >
0 commit comments