A platform for community discussion. Free, open, simple.
UX: Prevent color flicker on dark themes (#17620)
Joe3c558d2eb605
diff --git a/app/views/common/_discourse_splash.html.erb b/app/views/common/_discourse_splash.html.erbindex 40bf5e07578..3ce1009a694 100644--- a/app/views/common/_discourse_splash.html.erb+++ b/app/views/common/_discourse_splash.html.erb@@ -9,6 +9,11 @@<style>:root {--animation-state: paused;+ }++ /* user picked a theme where the "regular" scheme is dark */+ <%- if dark_color_scheme? %>+ :root {--primary: #<%= ColorScheme.hex_for_name("primary", scheme_id) %>;--secondary: #<%= ColorScheme.hex_for_name("secondary", scheme_id) %>;--tertiary: #<%= ColorScheme.hex_for_name("tertiary", scheme_id) %>;@@ -16,30 +21,33 @@--highlight: #<%= ColorScheme.hex_for_name("highlight", scheme_id) %>;--success: #<%= ColorScheme.hex_for_name("success", scheme_id) %>;}+ <%- else %>+ /* user picked a theme a light scheme and also enabled a dark scheme */++ /* deal with light scheme first */+ @media (prefers-color-scheme: light) {+ :root {+ --primary: #<%= ColorScheme.hex_for_name("primary", scheme_id) %>;+ --secondary: #<%= ColorScheme.hex_for_name("secondary", scheme_id) %>;+ --tertiary: #<%= ColorScheme.hex_for_name("tertiary", scheme_id) %>;+ --quaternary: #<%= ColorScheme.hex_for_name("quaternary", scheme_id) %>;+ --highlight: #<%= ColorScheme.hex_for_name("highlight", scheme_id) %>;+ --success: #<%= ColorScheme.hex_for_name("success", scheme_id) %>;+ }+ }+ /* then deal with dark scheme */@media (prefers-color-scheme: dark) {:root {- --animation-state: paused;--primary: #<%= ColorScheme.hex_for_name("primary", dark_scheme_id) %>;- --secondary: #<%= ColorScheme.hex_for_name(- "secondary",- dark_scheme_id- ) %>;- --tertiary: #<%= ColorScheme.hex_for_name(- "tertiary",- dark_scheme_id- ) %>;- --quaternary: #<%= ColorScheme.hex_for_name(- "quaternary",- dark_scheme_id- ) %>;- --highlight: #<%= ColorScheme.hex_for_name(- "highlight",- dark_scheme_id- ) %>;+ --secondary: #<%= ColorScheme.hex_for_name("secondary", dark_scheme_id) %>;+ --tertiary: #<%= ColorScheme.hex_for_name("tertiary", dark_scheme_id) %>;+ --quaternary: #<%= ColorScheme.hex_for_name("quaternary", dark_scheme_id) %>;+ --highlight: #<%= ColorScheme.hex_for_name("highlight", dark_scheme_id) %>;--success: #<%= ColorScheme.hex_for_name("success", dark_scheme_id) %>;}}+ <%- end %>/* these styles need to live here because the SVG has a different scope */.dots {@@ -114,14 +122,47 @@<style>html {overflow-y: hidden !important;+ }++ /* user picked a theme where the "regular" scheme is dark */+ <%- if dark_color_scheme? %>+ html {background-color: #<%= ColorScheme.hex_for_name("secondary", scheme_id) %>;}+ #d-splash .preloader-text-wrapper {+ color: #<%= ColorScheme.hex_for_name("primary", scheme_id) %>;+ }+ <%- else %>+ /* user picked a theme a light scheme and also enabled a dark scheme */++ /* deal with light scheme first */+ @media (prefers-color-scheme: light) {+ html {+ background-color: #<%= ColorScheme.hex_for_name("secondary", scheme_id) %>;+ }++ #d-splash .preloader-text-wrapper {+ color: #<%= ColorScheme.hex_for_name("primary", scheme_id) %>;+ }+ }++ /* then deal with dark scheme */+ @media (prefers-color-scheme: dark) {+ html {+ background-color: #<%= ColorScheme.hex_for_name("secondary", dark_scheme_id) %>;+ }++ #d-splash .preloader-text-wrapper {+ color: #<%= ColorScheme.hex_for_name("primary", dark_scheme_id) %>;+ }+ }+ <%- end %>+#d-splash {display: grid;place-items: center;backface-visibility: hidden;- background-color: #<%= ColorScheme.hex_for_name("secondary", scheme_id) %>;position: absolute;left: 0;top: 0;@@ -142,7 +183,6 @@animation-delay: 1s;animation-fill-mode: forwards;animation-play-state: var(--animation-state);- color: #<%= ColorScheme.hex_for_name("primary", scheme_id) %>;margin-bottom: -4em;}@@ -182,18 +222,6 @@content: "...";}}-- @media (prefers-color-scheme: dark) {- html {- background-color: #<%= ColorScheme.hex_for_name("secondary", dark_scheme_id) %>;- }- #d-splash {- background-color: #<%= ColorScheme.hex_for_name("secondary", dark_scheme_id) %>;- }- #d-splash .preloader-text-wrapper {- color: #<%= ColorScheme.hex_for_name("primary", dark_scheme_id) %>;- }- }</style><imgdiff --git a/app/views/layouts/_head.html.erb b/app/views/layouts/_head.html.erbindex 2f077d6788f..12db631ba84 100644--- a/app/views/layouts/_head.html.erb+++ b/app/views/layouts/_head.html.erb@@ -6,8 +6,7 @@<%- if site_apple_touch_icon_url.present? %><link rel="apple-touch-icon" type="image/png" href="<%= ::UrlHelper.absolute(site_apple_touch_icon_url) %>"><%- end %>-<meta name="theme-color" content="#<%= ColorScheme.hex_for_name('header_background', scheme_id) %>" media="(prefers-color-scheme: light)">-<meta name="theme-color" content="#<%= ColorScheme.hex_for_name('header_background', dark_scheme_id) %>" media="(prefers-color-scheme: dark)">+<meta name="theme-color" content="#<%= ColorScheme.hex_for_name('header_background', scheme_id) %>"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=yes, viewport-fit=cover"><%- if Discourse.base_path.present? %><meta name="discourse-base-uri" content="<%= Discourse.base_path %>">