File tree Expand file tree Collapse file tree 3 files changed +23
-9
lines changed Expand file tree Collapse file tree 3 files changed +23
-9
lines changed Original file line number Diff line number Diff line change @@ -69,13 +69,11 @@ const addShortestNotation = color => {
6969const addAliases = ( acc , curr ) => {
7070 if ( ! acc [ curr . key ] ) {
7171 acc [ curr . key ] = {
72- key : curr . key ,
7372 aliases : [ ]
7473 }
7574 }
7675
7776 acc [ curr . key ] = {
78- ...acc [ curr . key ] ,
7977 aliases : [ ...acc [ curr . key ] . aliases , curr ]
8078 }
8179
@@ -93,17 +91,21 @@ const validateColor = color => {
9391
9492const normalizeColors = color => {
9593 // Add a normalized value
94+
95+ // Avoid using TinyColor's toHslString() because it rounds
96+ // the numbers and incorrectly reports aliases
97+ const { h, s, l, a} = tinycolor ( color . value ) . toHsl ( )
98+
9699 return {
97100 ...color ,
98- key : tinycolor ( color . value ) . toHslString ( )
101+ key : `h ${ h } s ${ s } l ${ l } a ${ a } `
99102 }
100103}
101104
102105const rmTmpProps = color => {
103106 // Remove temporary props that were needed for analysis
104- const { key, ...restColor } = color
105107 return {
106- ...restColor ,
108+ ...color ,
107109 aliases : color . aliases . map ( alias => {
108110 const { key, ...restAlias } = alias
109111 return restAlias
Original file line number Diff line number Diff line change 6868 color : rgba (0 , 0 , 0 , 1 );
6969 color : hsl (0 , 0 , 0 );
7070 color : hsla (0 , 0 , 0 , 1 );
71+
72+ /* Almost duplicates */
73+ color : # d9d9d9 ;
74+ color : # dadada ;
7175}
7276.color-keyword {
7377 outline : 1px solid tomato;
Original file line number Diff line number Diff line change 11{
2- "total" : 91 ,
2+ "total" : 93 ,
33 "fontfamilies" : {
44 "total" : 18 ,
55 "totalUnique" : 12 ,
121121 "count" : 1
122122 }
123123 ],
124- "share" : 0.04395604395604396
124+ "share" : 0.043010752688172046
125125 },
126126 "colors" : {
127- "total" : 37 ,
128- "totalUnique" : 35 ,
127+ "total" : 39 ,
128+ "totalUnique" : 37 ,
129129 "unique" : [
130130 {
131131 "value" : " #000" ,
147147 "value" : " #aff034" ,
148148 "count" : 1
149149 },
150+ {
151+ "value" : " #d9d9d9" ,
152+ "count" : 1
153+ },
154+ {
155+ "value" : " #dadada" ,
156+ "count" : 1
157+ },
150158 {
151159 "value" : " #fff" ,
152160 "count" : 1
You can’t perform that action at this time.
0 commit comments