A platform for community discussion. Free, open, simple.
FIX: ensure dark variables and mobile width for experimental splash (#37486)
Kris22b393b6a26d
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rbindex 230c5d9c963..cda192e83d0 100644--- a/app/helpers/application_helper.rb+++ b/app/helpers/application_helper.rb@@ -507,16 +507,17 @@ module ApplicationHelper@splash_screen_image_animatedend- def splash_screen_image_data_uri+ def splash_screen_image_data_uri(dark: false)build_splash_screen_image unless defined?(@splash_screen_image_svg)return nil if @splash_screen_image_svg.blank?# Replace CSS variable references with actual theme colorssvg_with_colors = @splash_screen_image_svg.dup- primary = "##{light_color_hex_for_name("primary")}"- secondary = "##{light_color_hex_for_name("secondary")}"- tertiary = "##{light_color_hex_for_name("tertiary")}"+ color_method = dark ? :dark_color_hex_for_name : :light_color_hex_for_name+ primary = "##{public_send(color_method, "primary")}"+ secondary = "##{public_send(color_method, "secondary")}"+ tertiary = "##{public_send(color_method, "tertiary")}"svg_with_colors.gsub!(/var\(\s*--primary\s*\)/, primary)svg_with_colors.gsub!(/var\(\s*--secondary\s*\)/, secondary)diff --git a/app/views/common/_discourse_splash.html.erb b/app/views/common/_discourse_splash.html.erbindex 63df3e32fe3..e76d8e3991b 100644--- a/app/views/common/_discourse_splash.html.erb+++ b/app/views/common/_discourse_splash.html.erb@@ -16,6 +16,9 @@#d-splash {--dot-color: #<%= light_color_hex_for_name("tertiary") %>;+ <%- if custom_splash_screen_enabled? %>+ --splash-bg: url("<%= splash_screen_image_data_uri %>");+ <%- end %>}<%- elsif forced_light_mode? %>html {@@ -24,6 +27,9 @@#d-splash {--dot-color: #<%= light_color_hex_for_name("tertiary") %>;+ <%- if custom_splash_screen_enabled? %>+ --splash-bg: url("<%= splash_screen_image_data_uri %>");+ <%- end %>}<%- elsif forced_dark_mode? %>html {@@ -32,6 +38,9 @@#d-splash {--dot-color: #<%= dark_color_hex_for_name("tertiary") %>;+ <%- if custom_splash_screen_enabled? %>+ --splash-bg: url("<%= splash_screen_image_data_uri(dark: true) %>");+ <%- end %>}<%- else %>/* user picked a theme a light scheme and also enabled a dark scheme */@@ -44,6 +53,9 @@#d-splash {--dot-color: #<%= light_color_hex_for_name("tertiary") %>;+ <%- if custom_splash_screen_enabled? %>+ --splash-bg: url("<%= splash_screen_image_data_uri %>");+ <%- end %>}}@@ -55,6 +67,9 @@#d-splash {--dot-color: #<%= dark_color_hex_for_name("tertiary") %>;+ <%- if custom_splash_screen_enabled? %>+ --splash-bg: url("<%= splash_screen_image_data_uri(dark: true) %>");+ <%- end %>}}<%- end %>@@ -74,6 +89,9 @@--splash-dot-spacing: calc(var(--splash-dot-size) * 1.5);<%- if custom_splash_screen_enabled? %>width: 700px;+ @media (width < 700px) {+ width: 320px;+ }display: flex;flex-direction: column;align-items: center;@@ -157,7 +175,7 @@background-size: contain;background-repeat: no-repeat;background-position: center;- background-image: url("<%= splash_screen_image_data_uri %>");+ background-image: var(--splash-bg);<%- unless splash_screen_image_animated? %>opacity: 0.4;animation: d-splash-logo-pulse 3s ease-in-out infinite;