mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: lighten instead of adding transparency to consolidated pageviews (#7495)
This commit is contained in:
parent
2570311718
commit
626534ad94
@ -295,7 +295,25 @@ class Report
|
|||||||
add_counts report, subject, 'topics.created_at'
|
add_counts report, subject, 'topics.created_at'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def lighten_color(hex, amount)
|
||||||
|
hex = adjust_hex(hex)
|
||||||
|
rgb = hex.scan(/../).map { |color| color.hex }
|
||||||
|
rgb[0] = [(rgb[0].to_i + 255 * amount).round, 255].min
|
||||||
|
rgb[1] = [(rgb[1].to_i + 255 * amount).round, 255].min
|
||||||
|
rgb[2] = [(rgb[2].to_i + 255 * amount).round, 255].min
|
||||||
|
"#%02x%02x%02x" % rgb
|
||||||
|
end
|
||||||
|
|
||||||
def rgba_color(hex, opacity = 1)
|
def rgba_color(hex, opacity = 1)
|
||||||
|
rgbs = hex_to_rgbs(adjust_hex(hex))
|
||||||
|
"rgba(#{rgbs.join(',')},#{opacity})"
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def adjust_hex(hex)
|
||||||
|
hex = hex.gsub('#', '')
|
||||||
|
|
||||||
if hex.size == 3
|
if hex.size == 3
|
||||||
chars = hex.scan(/\w/)
|
chars = hex.scan(/\w/)
|
||||||
hex = chars.zip(chars).flatten.join
|
hex = chars.zip(chars).flatten.join
|
||||||
@ -305,13 +323,9 @@ class Report
|
|||||||
hex = hex.ljust(6, hex.last)
|
hex = hex.ljust(6, hex.last)
|
||||||
end
|
end
|
||||||
|
|
||||||
rgbs = hex_to_rgbs(hex)
|
hex
|
||||||
|
|
||||||
"rgba(#{rgbs.join(',')},#{opacity})"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def hex_to_rgbs(hex_color)
|
def hex_to_rgbs(hex_color)
|
||||||
hex_color = hex_color.gsub('#', '')
|
hex_color = hex_color.gsub('#', '')
|
||||||
rgbs = hex_color.scan(/../)
|
rgbs = hex_color.scan(/../)
|
||||||
|
@ -14,7 +14,7 @@ Report.add_report("consolidated_page_views") do |report|
|
|||||||
color = report.rgba_color(tertiary)
|
color = report.rgba_color(tertiary)
|
||||||
|
|
||||||
if filter == "page_view_anon"
|
if filter == "page_view_anon"
|
||||||
color = report.rgba_color(tertiary, 0.5)
|
color = report.lighten_color(tertiary, 0.25)
|
||||||
end
|
end
|
||||||
|
|
||||||
if filter == "page_view_crawler"
|
if filter == "page_view_crawler"
|
||||||
|
Loading…
Reference in New Issue
Block a user