mirror of
https://github.com/discourse/discourse.git
synced 2025-08-17 18:04:11 +08:00
UX: Don't make seeded palettes user-selectable (#34347)
Internal topic: t/160871.
This commit is contained in:
parent
3eb7de0f74
commit
77b774e7b3
4 changed files with 4 additions and 18 deletions
|
@ -402,7 +402,6 @@ class ColorScheme < ActiveRecord::Base
|
|||
new_color_scheme = new(name: params[:name])
|
||||
new_color_scheme.via_wizard = true if params[:via_wizard]
|
||||
new_color_scheme.base_scheme_id = params[:base_scheme_id]
|
||||
new_color_scheme.user_selectable = true
|
||||
|
||||
colors =
|
||||
BUILT_IN_SCHEMES[params[:base_scheme_id].to_sym]&.map do |name, hex|
|
||||
|
|
|
@ -24,7 +24,6 @@ if !theme_exists
|
|||
name: cs[:name],
|
||||
via_wizard: true,
|
||||
base_scheme_id: cs[:base_scheme_id],
|
||||
user_selectable: true,
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -979,7 +979,7 @@ RSpec.describe Stylesheet::Manager do
|
|||
|
||||
# Ensure we force compile each theme only once
|
||||
expect(output.scan(/#{child_theme_with_css.name}/).length).to eq(2) # ltr/rtl
|
||||
expect(StylesheetCache.count).to eq(34) # (1 theme with rtl/ltr) + 32 color schemes (2 themes * 8 color schemes (7 defaults + 1 theme scheme) * 2 (light and dark mode per scheme))
|
||||
expect(StylesheetCache.count).to eq(10) # (2 theme with rtl/ltr) + 8 color schemes (2 themes * 2 color schemes (1 base light palette + 1 theme scheme) * 2 (light and dark mode per scheme))
|
||||
end
|
||||
|
||||
it "generates precompiled CSS - core and themes" do
|
||||
|
@ -987,7 +987,7 @@ RSpec.describe Stylesheet::Manager do
|
|||
Stylesheet::Manager.precompile_theme_css
|
||||
|
||||
results = StylesheetCache.pluck(:target)
|
||||
expect(results.size).to eq(44) # 10 core targets + 2 theme (ltr/rtl) + 32 color schemes (light and dark mode per scheme)
|
||||
expect(results.size).to eq(20) # 10 core targets + 2 theme (ltr/rtl) + 8 color schemes (light and dark mode per scheme)
|
||||
|
||||
expect(results.count { |target| target =~ /^common_theme_/ }).to eq(2) # ltr/rtl
|
||||
end
|
||||
|
@ -999,7 +999,7 @@ RSpec.describe Stylesheet::Manager do
|
|||
Stylesheet::Manager.precompile_theme_css
|
||||
|
||||
results = StylesheetCache.pluck(:target)
|
||||
expect(results.size).to eq(58) # 10 core targets + theme rtl/ltr + 32 color schemes (light and dark mode per scheme) + 14 Foundation
|
||||
expect(results.size).to eq(24) # 10 core targets + 2 theme rtl/ltr + 12 color schemes (light and dark mode per scheme)
|
||||
|
||||
expect(results).to include("color_definitions_#{scheme1.name}_#{scheme1.id}_#{user_theme.id}")
|
||||
expect(results).to include(
|
||||
|
|
|
@ -88,24 +88,12 @@ RSpec.describe SiteSerializer do
|
|||
end
|
||||
|
||||
it "includes user-selectable color schemes" do
|
||||
# it includes seeded color schemes
|
||||
serialized = described_class.new(Site.new(guardian), scope: guardian, root: false).as_json
|
||||
expect(serialized[:user_color_schemes].count).to eq(6)
|
||||
|
||||
scheme_names = serialized[:user_color_schemes].map { |x| x[:name] }
|
||||
expect(scheme_names).to include(I18n.t("color_schemes.dark"))
|
||||
expect(scheme_names).to include(I18n.t("color_schemes.wcag"))
|
||||
expect(scheme_names).to include(I18n.t("color_schemes.wcag_dark"))
|
||||
expect(scheme_names).to include(I18n.t("color_schemes.solarized_light"))
|
||||
expect(scheme_names).to include(I18n.t("color_schemes.solarized_dark"))
|
||||
expect(scheme_names).to include(I18n.t("color_schemes.dracula"))
|
||||
|
||||
dark_scheme = ColorScheme.create_from_base(name: "AnotherDarkScheme", base_scheme_id: "Dark")
|
||||
dark_scheme.user_selectable = true
|
||||
dark_scheme.save!
|
||||
|
||||
serialized = described_class.new(Site.new(guardian), scope: guardian, root: false).as_json
|
||||
expect(serialized[:user_color_schemes].count).to eq(7)
|
||||
expect(serialized[:user_color_schemes].count).to eq(1)
|
||||
expect(serialized[:user_color_schemes][0][:is_dark]).to eq(true)
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue