mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 02:40:53 -06:00
FIX: makes sure an hex is always at 6 chars (#6608)
eg: #aaa should be converted to #aaaaaa
This commit is contained in:
parent
1c678c8c54
commit
761003c8bd
@ -1325,6 +1325,15 @@ class Report
|
||||
end
|
||||
|
||||
def rgba_color(hex, opacity = 1)
|
||||
if hex.length === 3
|
||||
chars = hex.scan(/\w/)
|
||||
hex = chars.zip(chars).flatten.join.ljust(6)
|
||||
end
|
||||
|
||||
if hex.length < 3
|
||||
hex = hex.ljust(6, hex.last)
|
||||
end
|
||||
|
||||
rgbs = hex_to_rgbs(hex)
|
||||
|
||||
"rgba(#{rgbs.join(',')},#{opacity})"
|
||||
|
Loading…
Reference in New Issue
Block a user