@@ -34,6 +34,9 @@ const styles = theme => ({
34
34
justifyContent : 'center' ,
35
35
alignItems : 'center' ,
36
36
} ,
37
+ swatch : {
38
+ width : 192 ,
39
+ } ,
37
40
sliderContainer : {
38
41
display : 'flex' ,
39
42
alignItems : 'center' ,
@@ -127,32 +130,6 @@ class ColorTool extends React.Component {
127
130
const { classes, theme } = this . props ;
128
131
const { primaryShade, secondaryShade } = this . state ;
129
132
130
- const colorTile = ( hue , colorIntent ) => {
131
- const shade = colorIntent === 'primary' ? shades [ primaryShade ] : shades [ secondaryShade ] ;
132
- const backgroundColor = colors [ hue ] [ shade ] ;
133
-
134
- return (
135
- < Tooltip placement = "right" id = { `tooltip-${ colorIntent } -${ hue } ` } title = { hue } key = { hue } >
136
- < Radio
137
- color = "default"
138
- checked = { this . state [ colorIntent ] === backgroundColor }
139
- onChange = { this . handleChangeHue ( colorIntent ) }
140
- value = { hue }
141
- name = { colorIntent }
142
- aria-labelledby = { `tooltip-${ colorIntent } -${ hue } ` }
143
- icon = { < div className = { classes . radio } style = { { backgroundColor } } /> }
144
- checkedIcon = {
145
- < div className = { classes . radioSelected } style = { { backgroundColor } } >
146
- < CheckIcon style = { { fontSize : 30 } } />
147
- </ div >
148
- }
149
- />
150
- </ Tooltip >
151
- ) ;
152
- } ;
153
-
154
- const colorSwatch = value => hues . map ( hue => colorTile ( hue , value ) ) ;
155
-
156
133
const colorBar = color => {
157
134
const background = { main : color } ;
158
135
theme . palette . augmentColor ( background ) ;
@@ -209,7 +186,31 @@ class ColorTool extends React.Component {
209
186
/>
210
187
< Typography > { shades [ intentShade ] } </ Typography >
211
188
</ div >
212
- < div > { colorSwatch ( intent ) } </ div >
189
+ < div className = { classes . swatch } >
190
+ { hues . map ( hue => {
191
+ const shade = intent === 'primary' ? shades [ primaryShade ] : shades [ secondaryShade ] ;
192
+ const backgroundColor = colors [ hue ] [ shade ] ;
193
+
194
+ return (
195
+ < Tooltip placement = "right" title = { hue } key = { hue } >
196
+ < Radio
197
+ color = "default"
198
+ checked = { this . state [ intent ] === backgroundColor }
199
+ onChange = { this . handleChangeHue ( intent ) }
200
+ value = { hue }
201
+ name = { intent }
202
+ aria-labelledby = { `tooltip-${ intent } -${ hue } ` }
203
+ icon = { < div className = { classes . radio } style = { { backgroundColor } } /> }
204
+ checkedIcon = {
205
+ < div className = { classes . radioSelected } style = { { backgroundColor } } >
206
+ < CheckIcon style = { { fontSize : 30 } } />
207
+ </ div >
208
+ }
209
+ />
210
+ </ Tooltip >
211
+ ) ;
212
+ } ) }
213
+ </ div >
213
214
{ colorBar ( color ) }
214
215
</ Grid >
215
216
) ;
0 commit comments