UX: Tweaks to admin color palette dropdown (#10502)

This commit is contained in:
Penar Musaraj 2020-08-21 09:30:11 -04:00 committed by GitHub
parent f51ccea028
commit 8b2c4b07a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 14 additions and 5 deletions

View File

@ -10,11 +10,22 @@ export default SelectKitRowComponent.extend({
palettes: computed("item.colors.[]", function() {
return (this.item.colors || [])
.filter(color => color.name !== "secondary")
.map(color => `#${escapeExpression(color.hex)}`)
.map(
hex => `<span class="palette" style="background-color:${hex}"></span>`
)
.join("")
.htmlSafe();
}),
backgroundColor: computed("item.colors.[]", function() {
const secondary = (this.item.colors || []).findBy("name", "secondary");
if (secondary && secondary.hex) {
return `background-color:#${escapeExpression(secondary.hex)}`.htmlSafe();
} else {
return "";
}
})
});

View File

@ -3,7 +3,7 @@
</span>
{{#if item.colors}}
<div class="palettes">
<div class="palettes" style={{backgroundColor}}>
{{palettes}}
</div>
{{/if}}

View File

@ -7,6 +7,7 @@
align-items: center;
margin-left: 0.5em;
flex: 1 0 0;
padding: 8px;
.palette {
height: 15px;

View File

@ -135,8 +135,6 @@ class Admin::ThemesController < Admin::AdminController
theme_fields: :upload
)
@color_schemes = ColorScheme.all.includes(:theme, color_scheme_colors: :color_scheme).to_a
light = ColorScheme.new(name: I18n.t("color_schemes.light_default"))
@color_schemes.unshift(light)
payload = {
themes: ActiveModel::ArraySerializer.new(@themes, each_serializer: ThemeSerializer),

View File

@ -3874,7 +3874,6 @@ en:
color_schemes:
base_theme_name: "Base"
light: "Light"
light_default: "Light (default)"
dark: "Dark"
neutral: "Neutral"
grey_amber: "Grey Amber"

View File

@ -252,7 +252,7 @@ describe Admin::ThemesController do
json = response.parsed_body
expect(json["extras"]["color_schemes"].length).to eq(2)
expect(json["extras"]["color_schemes"].length).to eq(1)
theme_json = json["themes"].find { |t| t["id"] == theme.id }
expect(theme_json["theme_fields"].length).to eq(2)
expect(theme_json["remote_theme"]["remote_version"]).to eq("7")