Apply theme colours to turbolinks progress bar

This commit is contained in:
Karina Kwiatek 2021-04-04 16:23:11 +02:00 committed by Dominik M. Kwiatek
parent 45cb0cab26
commit 1eb256ee88
4 changed files with 23 additions and 0 deletions

View File

@ -90,6 +90,8 @@ $avatar-sizes: (
--body-text: 0, 0, 0; --body-text: 0, 0, 0;
--muted-text: 108, 117, 125; --muted-text: 108, 117, 125;
--input-text: 0, 0, 0; --input-text: 0, 0, 0;
--turbolinks-progress-color: #a58adc; // --primary lightened by 25%
} }
$gray: #e2e2e2; $gray: #e2e2e2;

View File

@ -51,6 +51,7 @@
"overrides/minicolors", "overrides/minicolors",
"overrides/modal", "overrides/modal",
"overrides/navbar", "overrides/navbar",
"overrides/turbolinks",
"overrides/sweet-alert"; "overrides/sweet-alert";
/** /**

View File

@ -0,0 +1,3 @@
.turbolinks-progress-bar {
background: var(--turbolinks-progress-color);
}

View File

@ -40,6 +40,7 @@ module ThemeHelper
body += "\t--#{ATTRIBUTE_MAP[k]}: ##{get_hex_color_from_theme_value(v)};\n" body += "\t--#{ATTRIBUTE_MAP[k]}: ##{get_hex_color_from_theme_value(v)};\n"
end end
end end
body += "\t--turbolinks-progress-color: ##{lighten(theme.primary_color)}\n"
body += "}" body += "}"
@ -70,4 +71,20 @@ module ThemeHelper
hexes = value.split(/(.{2})/).reject { |c| c.empty? } hexes = value.split(/(.{2})/).reject { |c| c.empty? }
hexes.map(&:hex).join(", ") hexes.map(&:hex).join(", ")
end end
def rgb_values_from_hex(value)
[
(value & 0xFF0000) >> 16, # R
(value & 0x00FF00) >> 8, # G
value & 0x0000FF # B
]
end
def rgb_to_hex(rgb_values)
rgb_values.map.with_index { |v, i| v << (2 - i) * 8 }.reduce(&:+).to_s(16)
end
def lighten(value, amount = 0.25)
rgb_to_hex(rgb_values_from_hex(value).map { |v| [(v + 255 * amount).round, 255].min })
end
end end