@@ -17,6 +17,28 @@ export function ColorPicker({ username, onColorChange }: ColorPickerProps) {
1717 const { t } = useTranslation ( ) ;
1818 const [ isSaving , setIsSaving ] = useState ( false ) ;
1919 const [ customColor , setCustomColor ] = useState ( accentColor ) ;
20+ const [ isLoading , setIsLoading ] = useState ( true ) ;
21+
22+ // Load user's actual accent color on mount
23+ useEffect ( ( ) => {
24+ const loadUserColor = async ( ) => {
25+ try {
26+ const userColor = await getUserAccentColor ( username ) ;
27+ setAccentColor ( userColor ) ;
28+ setCustomColor ( userColor ) ;
29+ } catch ( error ) {
30+ // Keep default color on error
31+ } finally {
32+ setIsLoading ( false ) ;
33+ }
34+ } ;
35+ loadUserColor ( ) ;
36+ } , [ username , setAccentColor ] ) ;
37+
38+ // Keep customColor in sync with accentColor
39+ useEffect ( ( ) => {
40+ setCustomColor ( accentColor ) ;
41+ } , [ accentColor ] ) ;
2042
2143 const handleColorSelect = async ( color : string ) => {
2244 // Apply color immediately for instant feedback
@@ -66,12 +88,12 @@ export function ColorPicker({ username, onColorChange }: ColorPickerProps) {
6688 < button
6789 key = { color }
6890 onClick = { ( ) => handleColorSelect ( color ) }
69- disabled = { isSaving }
91+ disabled = { isSaving || isLoading }
7092 className = { `relative w-12 h-12 rounded-lg border-2 transition-all hover:scale-110 ${
7193 accentColor === color
7294 ? 'border-gray-900 dark:border-gray-100 shadow-lg'
7395 : 'border-gray-300 dark:border-gray-600'
74- } `}
96+ } ${ isLoading || isSaving ? 'opacity-50 cursor-not-allowed' : '' } `}
7597 style = { { backgroundColor : color } }
7698 title = { color }
7799 >
@@ -92,18 +114,20 @@ export function ColorPicker({ username, onColorChange }: ColorPickerProps) {
92114 type = "color"
93115 value = { customColor }
94116 onChange = { ( e ) => handleCustomColorChange ( e . target . value ) }
95- className = "w-12 h-10 rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700"
117+ disabled = { isSaving || isLoading }
118+ className = "w-12 h-10 rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 disabled:opacity-50"
96119 />
97120 < input
98121 type = "text"
99122 value = { customColor }
100123 onChange = { ( e ) => handleCustomColorChange ( e . target . value ) }
101124 placeholder = "rgb(59, 130, 246)"
102- className = "flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100"
125+ disabled = { isSaving || isLoading }
126+ className = "flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 disabled:opacity-50"
103127 />
104128 < button
105129 onClick = { handleCustomColorApply }
106- disabled = { isSaving || customColor === accentColor }
130+ disabled = { isSaving || isLoading || customColor === accentColor }
107131 className = "px-4 py-2 btn-accent hover:opacity-90 disabled:opacity-50 text-white rounded-md transition-colors"
108132 >
109133 { isSaving ? t ( 'savingColor' ) : t ( 'apply' ) }
0 commit comments