Just sharing a quick follow up to inform that we are working on an automatic fix for sites that were impacted by the category text color change.
I will share another update here soon when I have more details.
Just sharing a quick follow up to inform that we are working on an automatic fix for sites that were impacted by the category text color change.
I will share another update here soon when I have more details.
Sites that we host have been auto corrected to the best contrasting text color.
For the majority of affected sites this was 2-3 categories and I think most won’t notice unless they are using the category banners theme component.
Here is a script for self hosted sites in case it is needed, it can be run from the rails console:
START_DATE = DateTime.new(2025, 3, 31)
CATEGORY_TEXT_COLORS = %w[FFFFFF 000000] # DO NOT CHANGE
UPDATE_LOG = []
def color_difference(color1, color2)
r1 = color1[0..1].to_i(16)
g1 = color1[2..3].to_i(16)
b1 = color1[4..5].to_i(16)
r2 = color2[0..1].to_i(16)
g2 = color2[2..3].to_i(16)
b2 = color2[4..5].to_i(16)
r_diff = (r1 - r2).abs
g_diff = (g1 - g2).abs
b_diff = (b1 - b2).abs
r_diff + g_diff + b_diff
end
categories_to_update = {}
Category
.where("updated_at > ?", START_DATE)
.find_each do |category|
text_color = category.text_color.upcase
# skip if category has a custom text color or badly formatted bg color
next if CATEGORY_TEXT_COLORS.exclude?(text_color) || category.color.size != 6
white_diff = color_difference(category.color, CATEGORY_TEXT_COLORS[0])
black_diff = color_difference(category.color, CATEGORY_TEXT_COLORS[1])
color_index = white_diff > black_diff ? 0 : 1
if text_color != CATEGORY_TEXT_COLORS[color_index]
categories_to_update[category.id] = { text_color: CATEGORY_TEXT_COLORS[color_index] }
end
end
# update categories with the new text color
Category
.where(id: categories_to_update.keys)
.find_each do |category|
change = categories_to_update[category.id]
next unless change
UPDATE_LOG << "Updated #{category.url} text color from ##{category.text_color} to ##{change[:text_color]}"
category.update_columns(text_color: change[:text_color])
end
puts "Updated #{categories_to_update.size} categories\n---"
puts UPDATE_LOG.join("\n")
So is it safe now that if I manually check my categories and adjust the colors again, you won’t change them in the next few weeks? I checked all of them about 3 weeks ago and now some category banners are difficult to read again, so this time I want to make sure that everything isn’t changed again a few days later.
Especially in combination with shades of red, I find the automatically applied black rather difficult to read
Turquoise tones have often been given a light font color.
The result for grey tones doesn’t always fit either. Here on meta, for example, Dev > Translations is written in black but Site feedback in white. (I know the color isn’t the same, but very similar)
Yes it is safe to manually change these as you wish.
We have no plans to change the colors further at the moment. There will definitely be some cases where both white and black text is legible, this is to be expected with certain color ranges.
That is certainly a question of taste, although I am surprised by some of the results when I check the accessibility with Web Accessibility Color Contrast Checker - Conform to WCAG
Documentation > Migrating to Discourse
The biggest surprise of these is the community wiki category, the white text is much easier to read for me (so the automated choice feels correct) but the contrast checker suggests black text is better. There is likely some level of taste/preference here like you suggested.
The tricky part is that we are looking specifically at contrast, whereas I think color brightness also influences what feels easier to read too.
Generally speaking I think this works quite well for the majority of color ranges. For example, if you choose a dark color it will suggest white text, for light colors it will suggest black text. There are some colors that are in between that could go either way, and in those cases the user can pick what feels right from the edit category page.