mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 21:04:33 +08:00
UX: add color-scheme meta tag to _head (#30245)
Adds the `color-scheme` meta tag to the `_head` partial and removes it from the finish installation template to prevent it from being added twice.
This commit is contained in:
@ -678,6 +678,20 @@ module ApplicationHelper
|
||||
result.html_safe
|
||||
end
|
||||
|
||||
def discourse_color_scheme_meta_tag
|
||||
scheme =
|
||||
if dark_scheme_id == -1
|
||||
# no automatic client-side switching
|
||||
dark_color_scheme? ? "dark" : "light"
|
||||
else
|
||||
# auto-switched based on browser setting
|
||||
"light dark"
|
||||
end
|
||||
<<~HTML.html_safe
|
||||
<meta name="color-scheme" content="#{scheme}">
|
||||
HTML
|
||||
end
|
||||
|
||||
def dark_color_scheme?
|
||||
return false if scheme_id.blank?
|
||||
ColorScheme.find_by_id(scheme_id)&.is_dark?
|
||||
|
Reference in New Issue
Block a user