@@ -29,7 +29,7 @@ export const hexToCssHsl = (hex: string, valuesOnly = false) => {
29
29
let h = 0 ;
30
30
let s = 0 ;
31
31
let l = ( max + min ) / 2 ;
32
- if ( max == min ) {
32
+ if ( max === min ) {
33
33
h = s = 0 ; // achromatic
34
34
} else {
35
35
const d = max - min ;
@@ -68,11 +68,11 @@ export const hexToHSL = (H: string) => {
68
68
let r = 0 ;
69
69
let g = 0 ;
70
70
let b = 0 ;
71
- if ( H . length == 4 ) {
71
+ if ( H . length === 4 ) {
72
72
r = parseInt ( '0x' + H [ 1 ] + H [ 1 ] ) ;
73
73
g = parseInt ( '0x' + H [ 2 ] + H [ 2 ] ) ;
74
74
b = parseInt ( '0x' + H [ 3 ] + H [ 3 ] ) ;
75
- } else if ( H . length == 7 ) {
75
+ } else if ( H . length === 7 ) {
76
76
r = parseInt ( '0x' + H [ 1 ] + H [ 2 ] ) ;
77
77
g = parseInt ( '0x' + H [ 3 ] + H [ 4 ] ) ;
78
78
b = parseInt ( '0x' + H [ 5 ] + H [ 6 ] ) ;
@@ -88,17 +88,17 @@ export const hexToHSL = (H: string) => {
88
88
const cmax = Math . max ( r , g , b ) ;
89
89
const delta = cmax - cmin ;
90
90
91
- if ( delta == 0 ) h = 0 ;
92
- else if ( cmax == r ) h = ( ( g - b ) / delta ) % 6 ;
93
- else if ( cmax == g ) h = ( b - r ) / delta + 2 ;
91
+ if ( delta === 0 ) h = 0 ;
92
+ else if ( cmax === r ) h = ( ( g - b ) / delta ) % 6 ;
93
+ else if ( cmax === g ) h = ( b - r ) / delta + 2 ;
94
94
else h = ( r - g ) / delta + 4 ;
95
95
96
96
h = Math . round ( h * 60 ) ;
97
97
98
98
if ( h < 0 ) h += 360 ;
99
99
100
100
l = ( cmax + cmin ) / 2 ;
101
- s = delta == 0 ? 0 : delta / ( 1 - Math . abs ( 2 * l - 1 ) ) ;
101
+ s = delta === 0 ? 0 : delta / ( 1 - Math . abs ( 2 * l - 1 ) ) ;
102
102
s = + ( s * 100 ) . toFixed ( 1 ) ;
103
103
l = + ( l * 100 ) . toFixed ( 1 ) ;
104
104
@@ -178,9 +178,9 @@ export const HSLToHex = (h: number, s: number, l: number) => {
178
178
b = parseInt ( Math . round ( ( b + m ) * 255 ) . toString ( 16 ) , 16 ) ;
179
179
180
180
// Prepend 0s, if necessary
181
- if ( r . toString ( ) . length == 1 ) r = parseInt ( '0' + r . toString ( ) , 10 ) ;
182
- if ( g . toString ( ) . length == 1 ) g = parseInt ( '0' + g . toString ( ) , 10 ) ;
183
- if ( b . toString ( ) . length == 1 ) b = parseInt ( '0' + b . toString ( ) , 10 ) ;
181
+ if ( r . toString ( ) . length === 1 ) r = parseInt ( '0' + r . toString ( ) , 10 ) ;
182
+ if ( g . toString ( ) . length === 1 ) g = parseInt ( '0' + g . toString ( ) , 10 ) ;
183
+ if ( b . toString ( ) . length === 1 ) b = parseInt ( '0' + b . toString ( ) , 10 ) ;
184
184
185
185
return '#' + r + g + b ;
186
186
} ;
0 commit comments