File tree Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -139,11 +139,13 @@ const color_cmyk = (val) => {
139
139
}
140
140
141
141
const color_hex = ( val ) => {
142
- if ( ! / ^ ( [ A - F a - f 0 - 9 ] { 6 } | [ A - F a - f 0 - 9 ] { 3 } ) $ / . test ( val ) ) {
142
+ const match = `${ val } ` . match ( / ^ # ? ( [ A - F a - f 0 - 9 ] { 6 } | [ A - F a - f 0 - 9 ] { 3 } ) $ / )
143
+
144
+ if ( ! match ) {
143
145
return false
144
146
}
145
147
146
- const hsb = convert . hex . hsv ( val )
148
+ const hsb = convert . hex . hsv ( match [ 1 ] )
147
149
148
150
return {
149
151
key : 'color' ,
@@ -292,11 +294,13 @@ const colorChangingLightDecorator = ({
292
294
localState . color . brightness * 100
293
295
)
294
296
295
- localState [ 'color_hex' ] = convert . hsv . hex (
296
- localState . color . hue ,
297
- localState . color . saturation * 100 ,
298
- localState . color . brightness * 100
299
- )
297
+ localState [ 'color_hex' ] =
298
+ '#' +
299
+ convert . hsv . hex (
300
+ localState . color . hue ,
301
+ localState . color . saturation * 100 ,
302
+ localState . color . brightness * 100
303
+ )
300
304
301
305
localState [ 'color_cmyk' ] = convert . hsv . cmyk (
302
306
localState . color . hue ,
Original file line number Diff line number Diff line change @@ -312,7 +312,10 @@ <h4>Color Changing Light Bulb</h4>
312
312
payload.color_hex
313
313
< span class = "property-type" > string</ span >
314
314
</ dt >
315
- < dd > Hexadecimal representation of < code > payload.color</ code > </ dd >
315
+ < dd >
316
+ Hexadecimal representation of < code > payload.color</ code > , e.g.
317
+ "#FF00AA"
318
+ </ dd >
316
319
< dt >
317
320
payload.color_cmyk
318
321
< span class = "property-type" > array(4)</ span >
You can’t perform that action at this time.
0 commit comments