A platform for community discussion. Free, open, simple.
FIX: In components, fall back to default theme color variables (#12423)
Penar Musarajeb7f0ec76662
diff --git a/lib/stylesheet/importer.rb b/lib/stylesheet/importer.rbindex 47f8e709a5d..bf2c1186548 100644--- a/lib/stylesheet/importer.rb+++ b/lib/stylesheet/importer.rb@@ -135,8 +135,11 @@ module StylesheetrescueColorScheme.base_colorsend+ elsif (@theme_id && theme.color_scheme)+ colors = theme.color_scheme.resolved_colorselse- colors = (@theme_id && theme.color_scheme) ? theme.color_scheme.resolved_colors : ColorScheme.base_colors+ colors = Theme.find_by_id(SiteSetting.default_theme_id)&.color_scheme&.resolved_colors ||+ ColorScheme.base_colorsendcolors.each do |n, hex|diff --git a/spec/components/stylesheet/manager_spec.rb b/spec/components/stylesheet/manager_spec.rbindex 97ab426f617..53079526d89 100644--- a/spec/components/stylesheet/manager_spec.rb+++ b/spec/components/stylesheet/manager_spec.rb@@ -415,6 +415,24 @@ describe Stylesheet::Manager doexpect { stylesheet.compile }.not_to raise_errorend++ it "child theme SCSS includes the default theme's color scheme variables" do+ SiteSetting.default_theme_id = theme.id+ custom_scheme = ColorScheme.create_from_base(name: "Neutral", base_scheme_id: "Neutral")+ ColorSchemeRevisor.revise(custom_scheme, colors: [{ name: "primary", hex: "CC0000" }])+ theme.color_scheme_id = custom_scheme.id+ theme.save!++ scss = "body{ border: 2px solid $primary;}"+ child.set_field(target: :common, name: "scss", value: scss)+ child.save!++ child_theme_manager = Stylesheet::Manager.new(:desktop_theme, child.id)+ child_theme_manager.compile(force: true)++ child_css = File.read(child_theme_manager.stylesheet_fullpath)+ expect(child_css).to include("body{border:2px solid #c00}")+ endendcontext 'encoded slugs' do