UX: Apply changes live when editing currently active palette (#31874)

When editing a color palette via the new page introduced in
https://github.com/discourse/discourse/pull/31742, it should apply the
color changes for the admin making the change automatically upon save.

Internal topic: t/148628/12.
This commit is contained in:
Osama Sayegh
2025-03-25 06:42:23 +03:00
committed by GitHub
parent 423191ea24
commit 1a4e09a23e
5 changed files with 120 additions and 5 deletions

View File

@ -341,7 +341,12 @@ class Stylesheet::Manager
end
end
def color_scheme_stylesheet_details(color_scheme_id = nil, dark: false, fallback_to_base: true)
def color_scheme_stylesheet_details(
color_scheme_id = nil,
dark: false,
fallback_to_base: true,
include_dark_scheme: false
)
theme_id = @theme_id || SiteSetting.default_theme_id
color_scheme = ColorScheme.find_by(id: color_scheme_id)
@ -373,6 +378,18 @@ class Stylesheet::Manager
href = builder.stylesheet_absolute_url
stylesheet[:new_href] = href
if include_dark_scheme
dark_href =
self.color_scheme_stylesheet_link_tag_href(
color_scheme_id,
dark: true,
fallback_to_base: false,
)
stylesheet[:new_dark_href] = dark_href if dark_href
end
stylesheet.freeze
end
end