File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -95,12 +95,13 @@ class SpritesCLI < Thor
95
95
96
96
def needs_dark_icon_fix ( icon , bg_color )
97
97
# Determine whether the icon needs to be grayscaled if the user has enabled the dark theme
98
- # The logic comes from https://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast
99
- contrast = icon . pixels . map do |pixel |
98
+ # The logic is roughly based on https://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast
99
+ contrast = icon . pixels . select { | pixel | ChunkyPNG :: Color . a ( pixel ) > 0 } . map do |pixel |
100
100
get_contrast ( bg_color , pixel )
101
101
end
102
102
103
- contrast . max < 7
103
+ avg = contrast . reduce ( :+ ) / contrast . size . to_f
104
+ avg < 3.5
104
105
end
105
106
106
107
def get_contrast ( base , other )
@@ -173,7 +174,8 @@ class SpritesCLI < Thor
173
174
174
175
def log_details ( items_with_icons , icons_per_row )
175
176
logger . debug ( "Amount of icons: #{ items_with_icons . length } " )
176
- logger . debug ( "Icons per row: #{ icons_per_row } " )
177
+ logger . debug ( "Amount of icons needing the dark icon fix: #{ items_with_icons . count { |item | item [ :dark_icon_fix ] } } " )
178
+ logger . debug ( "Amount of icons per row: #{ icons_per_row } " )
177
179
178
180
max_type_length = items_with_icons . map { |item | item [ :type ] . length } . max
179
181
border = "+#{ '-' * ( max_type_length + 2 ) } +#{ '-' * 5 } +#{ '-' * 8 } +#{ '-' * 15 } +"
You can’t perform that action at this time.
0 commit comments