DEV: Add more color schemes (#17398)

This commit is contained in:
Jordan Vidrine 2022-07-08 16:46:32 -05:00 committed by GitHub
parent e91cc340e6
commit fec3df60cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 118 additions and 7 deletions

View File

@ -125,6 +125,105 @@ class ColorScheme < ActiveRecord::Base
"danger" => 'BB1122',
"success" => '3d854d',
"love" => '9D256B'
},
# By @zenorocha
"Dracula": {
"primary_very_low" => "373A47",
"primary_low" => "414350",
"primary_low_mid" => "8C8D94",
"primary_medium" => "A3A4AA",
"primary_high" => "CCCCCF",
"primary" => 'f2f2f2',
"secondary_low" => "CCCCCF",
"secondary_medium" => "91939A",
"secondary_high" => "6A6C76",
"secondary_very_high" => "3D404C",
"secondary" => '2d303e',
"tertiary_low" => "4A4463",
"tertiary_medium" => "6E5D92",
"tertiary" => 'bd93f9',
"tertiary_high" => "9275C1",
"quaternary_low" => "6AA8BA",
"quaternary" => '8be9fd',
"header_background" => '373A47',
"header_primary" => 'f2f2f2',
"highlight_low" => "686D55",
"danger_medium" => "B6484D",
"highlight" => 'f1fa8c',
"highlight_high" => "C0C879",
"danger_low" => "957279",
"danger" => 'ff5555',
"success_low" => "386D50",
"success_medium" => "44B366",
"success" => '50fa7b',
"love_low" => "6C4667",
"love" => 'ff79c6'
},
# By @altercation
"Solarized Light": {
"primary_very_low" => "F0ECD7",
"primary_low" => "D6D8C7",
"primary_low_mid" => "A4AFA5",
"primary_medium" => "7E918C",
"primary_high" => "4C6869",
"primary" => '002B36',
"secondary_low" => "325458",
"secondary_medium" => "6C8280",
"secondary_high" => "97A59D",
"secondary_very_high" => "E8E6D3",
"secondary" => 'FCF6E1',
"tertiary_low" => "D6E6DE",
"tertiary_medium" => "7EBFD7",
"tertiary" => '0088cc',
"tertiary_high" => "329ED0",
"quaternary" => 'e45735',
"header_background" => 'FCF6E1',
"header_primary" => '002B36',
"highlight_low" => "FDF9AD",
"highlight_medium" => "E3D0A3",
"highlight" => 'ffff4d',
"highlight_high" => "BCAA7F",
"danger_low" => "F8D9C2",
"danger" => 'e45735',
"success_low" => "CFE5B9",
"success_medium" => "4CB544",
"success" => '009900',
"love_low" => "FCDDD2",
"love" => 'fa6c8d'
},
# By @altercation
"Solarized Dark": {
"primary_very_low" => "0D353F",
"primary_low" => "193F47",
"primary_low_mid" => "798C88",
"primary_medium" => "97A59D",
"primary_high" => "B5BDB1",
"primary" => 'FCF6E1',
"secondary_low" => "B5BDB1",
"secondary_medium" => "81938D",
"secondary_high" => "4E6A6B",
"secondary_very_high" => "143B44",
"secondary" => '002B36',
"tertiary_low" => "003E54",
"tertiary_medium" => "00557A",
"tertiary" => '0088cc',
"tertiary_high" => "006C9F",
"quaternary_low" => "944835",
"quaternary" => 'e45735',
"header_background" => '002B36',
"header_primary" => 'FCF6E1',
"highlight_low" => "4D6B3D",
"highlight_medium" => "464C33",
"highlight" => 'ffff4d',
"highlight_high" => "BFCA47",
"danger_low" => "443836",
"danger_medium" => "944835",
"danger" => 'e45735',
"success_low" => "004C26",
"success_medium" => "007313",
"success" => '009900',
"love_low" => "4B3F50",
"love" => 'fa6c8d',
}
}
@ -232,7 +331,7 @@ 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 if params[:user_selectable]
new_color_scheme.user_selectable = true
colors = CUSTOM_SCHEMES[params[:base_scheme_id].to_sym]&.map do |name, hex|
{ name: name, hex: hex }

View File

@ -4185,6 +4185,12 @@ en:
dark_rose: "Dark Rose"
wcag: "WCAG Light"
wcag_theme_name: "WCAG Light"
dracula: "Dracula"
dracula_theme_name: "Dracula"
solarized_light: "Solarized Light"
solarized_light_theme_name: "Solarized Light"
solarized_dark: "Solarized Dark"
solarized_dark_theme_name: "Solarized Dark"
wcag_dark: "WCAG Dark"
wcag_dark_theme_name: "WCAG Dark"
default_theme_name: "Default"

View File

@ -7,7 +7,10 @@ if !Theme.exists?
color_schemes = [
{ name: I18n.t("color_schemes.dark"), base_scheme_id: "Dark" },
{ name: I18n.t("color_schemes.wcag"), base_scheme_id: "WCAG" },
{ name: I18n.t("color_schemes.wcag_dark"), base_scheme_id: "WCAG Dark" }
{ name: I18n.t("color_schemes.wcag_dark"), base_scheme_id: "WCAG Dark" },
{ name: I18n.t("color_schemes.dracula"), base_scheme_id: "Dracula" },
{ name: I18n.t("color_schemes.solarized_light"), base_scheme_id: "Solarized Light" },
{ name: I18n.t("color_schemes.solarized_dark"), base_scheme_id: "Solarized Dark" }
]
color_schemes.each do |cs|

View File

@ -783,12 +783,12 @@ describe Stylesheet::Manager do
# Ensure we force compile each theme only once
expect(output.scan(/#{child_theme_with_css.name}/).length).to eq(2)
results = StylesheetCache.pluck(:target)
expect(results.size).to eq(16) # (3 themes * 2 targets) + 10 color schemes (2 themes * 5 color schemes (4 defaults + 1 theme scheme))
expect(results.size).to eq(22) # (3 themes * 2 targets) + 16 color schemes (2 themes * 8 color schemes (7 defaults + 1 theme scheme))
# themes + core
Stylesheet::Manager.precompile_css
results = StylesheetCache.pluck(:target)
expect(results.size).to eq(22) # 6 core targets + 6 theme + 10 color schemes
expect(results.size).to eq(28) # 9 core targets + 9 theme + 10 color schemes
theme_targets.each do |tar|
expect(results.count { |target| target =~ /^#{tar}_(#{user_theme.id}|#{default_theme.id})$/ }).to eq(2)
@ -801,7 +801,7 @@ describe Stylesheet::Manager do
Stylesheet::Manager.precompile_css
Stylesheet::Manager.precompile_theme_css
results = StylesheetCache.pluck(:target)
expect(results.size).to eq(22) # 6 core targets + 6 theme + 10 color schemes
expect(results.size).to eq(28) # 9 core targets + 9 theme + 10 color schemes
expect(results).to include("color_definitions_#{scheme1.name}_#{scheme1.id}_#{user_theme.id}")
expect(results).to include("color_definitions_#{scheme2.name}_#{scheme2.id}_#{default_theme.id}")

View File

@ -72,19 +72,22 @@ describe SiteSerializer do
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(3)
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(4)
expect(serialized[:user_color_schemes].count).to eq(7)
expect(serialized[:user_color_schemes][0][:is_dark]).to eq(true)
end