How does Discourse generate random colors for categories?


(Frank) #1

Hi,

How does Discourse generate those nice random colors for its categories? Is the color set in the database, stylesheet or JavaScript? It’d be great if someone could point me to the relevant place in the source code.

I tried with jquery-color but the result isn’t as nice:

http://jsfiddle.net/h7uzmv5r/1/

Thanks!


(Daniel) #2

They are not generated but are set in the config file.

The default colours are:

'BF1E2E|F1592A|F7941D|9EB83B|3AB54A|12A89D|25AAE2|0E76BD|652D90|92278F|ED207B|8C6238|231F20|808281|B3B5B4|283890'


(Frank) #3

Great, thanks!

Can you tell a little bit more about how they’re being applied to each category though?


(Kane York) #4

The admin picks the color in the category settings for each one; it included a free-text color entry box too.