@@ -6,10 +6,6 @@ import { Slider } from "./Slider.tsx";
6
6
import { Thumb } from "./Thumb.tsx" ;
7
7
import { type ColorEditorProps } from "./types.ts" ;
8
8
9
- const red = new RgbColor ( 1 , 0 , 0 ) ;
10
- const green = new RgbColor ( 0 , 1 , 0 ) ;
11
- const blue = new RgbColor ( 0 , 0 , 1 ) ;
12
-
13
9
export function ColorPicker ( { color, onChange } : ColorEditorProps ) {
14
10
const { h, s, v } = color . toHsv ( ) ;
15
11
const { r, g, b } = color . toRgb ( ) ;
@@ -32,7 +28,7 @@ export function ColorPicker({ color, onChange }: ColorEditorProps) {
32
28
onChange ( new HsvColor ( h , x , y ) ) ;
33
29
} }
34
30
>
35
- < Thumb color = { color . fade ( 1 ) } value = { saturationValue } />
31
+ < Thumb color = { color } value = { saturationValue } />
36
32
</ Slider >
37
33
< Spacer size = { 1 } />
38
34
< Slider
@@ -50,38 +46,38 @@ export function ColorPicker({ color, onChange }: ColorEditorProps) {
50
46
< Slider
51
47
className = { styles . channel }
52
48
style = { {
53
- backgroundImage : `linear-gradient(to right,#000,#f00 )` ,
49
+ backgroundImage : `linear-gradient(to right,${ new RgbColor ( 0 , g , b ) } , ${ new RgbColor ( 1 , g , b ) } )` ,
54
50
} }
55
51
value = { rValue }
56
52
onChange = { ( { x } ) => {
57
53
onChange ( new RgbColor ( x , g , b ) ) ;
58
54
} }
59
55
>
60
- < Thumb color = { red } value = { rValue } />
56
+ < Thumb color = { color } value = { rValue } />
61
57
</ Slider >
62
58
< Slider
63
59
className = { styles . channel }
64
60
style = { {
65
- backgroundImage : `linear-gradient(to right,#000,#0f0 )` ,
61
+ backgroundImage : `linear-gradient(to right,${ new RgbColor ( r , 0 , b ) } , ${ new RgbColor ( r , 1 , b ) } )` ,
66
62
} }
67
63
value = { gValue }
68
64
onChange = { ( { x } ) => {
69
65
onChange ( new RgbColor ( r , x , b ) ) ;
70
66
} }
71
67
>
72
- < Thumb color = { green } value = { gValue } />
68
+ < Thumb color = { color } value = { gValue } />
73
69
</ Slider >
74
70
< Slider
75
71
className = { styles . channel }
76
72
style = { {
77
- backgroundImage : `linear-gradient(to right,#000,#00f )` ,
73
+ backgroundImage : `linear-gradient(to right,${ new RgbColor ( r , g , 0 ) } , ${ new RgbColor ( r , g , 1 ) } )` ,
78
74
} }
79
75
value = { gValue }
80
76
onChange = { ( { x } ) => {
81
77
onChange ( new RgbColor ( r , g , x ) ) ;
82
78
} }
83
79
>
84
- < Thumb color = { blue } value = { bValue } />
80
+ < Thumb color = { color } value = { bValue } />
85
81
</ Slider >
86
82
< ColorInput color = { color } onChange = { onChange } />
87
83
</ div >
0 commit comments