mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 11:48:26 -06:00
UX: Tweaks to admin color palette dropdown (#10502)
This commit is contained in:
parent
f51ccea028
commit
8b2c4b07a4
@ -10,11 +10,22 @@ export default SelectKitRowComponent.extend({
|
|||||||
|
|
||||||
palettes: computed("item.colors.[]", function() {
|
palettes: computed("item.colors.[]", function() {
|
||||||
return (this.item.colors || [])
|
return (this.item.colors || [])
|
||||||
|
.filter(color => color.name !== "secondary")
|
||||||
.map(color => `#${escapeExpression(color.hex)}`)
|
.map(color => `#${escapeExpression(color.hex)}`)
|
||||||
.map(
|
.map(
|
||||||
hex => `<span class="palette" style="background-color:${hex}"></span>`
|
hex => `<span class="palette" style="background-color:${hex}"></span>`
|
||||||
)
|
)
|
||||||
.join("")
|
.join("")
|
||||||
.htmlSafe();
|
.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 "";
|
||||||
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
</span>
|
</span>
|
||||||
|
|
||||||
{{#if item.colors}}
|
{{#if item.colors}}
|
||||||
<div class="palettes">
|
<div class="palettes" style={{backgroundColor}}>
|
||||||
{{palettes}}
|
{{palettes}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
margin-left: 0.5em;
|
margin-left: 0.5em;
|
||||||
flex: 1 0 0;
|
flex: 1 0 0;
|
||||||
|
padding: 8px;
|
||||||
|
|
||||||
.palette {
|
.palette {
|
||||||
height: 15px;
|
height: 15px;
|
||||||
|
@ -135,8 +135,6 @@ class Admin::ThemesController < Admin::AdminController
|
|||||||
theme_fields: :upload
|
theme_fields: :upload
|
||||||
)
|
)
|
||||||
@color_schemes = ColorScheme.all.includes(:theme, color_scheme_colors: :color_scheme).to_a
|
@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 = {
|
payload = {
|
||||||
themes: ActiveModel::ArraySerializer.new(@themes, each_serializer: ThemeSerializer),
|
themes: ActiveModel::ArraySerializer.new(@themes, each_serializer: ThemeSerializer),
|
||||||
|
@ -3874,7 +3874,6 @@ en:
|
|||||||
color_schemes:
|
color_schemes:
|
||||||
base_theme_name: "Base"
|
base_theme_name: "Base"
|
||||||
light: "Light"
|
light: "Light"
|
||||||
light_default: "Light (default)"
|
|
||||||
dark: "Dark"
|
dark: "Dark"
|
||||||
neutral: "Neutral"
|
neutral: "Neutral"
|
||||||
grey_amber: "Grey Amber"
|
grey_amber: "Grey Amber"
|
||||||
|
@ -252,7 +252,7 @@ describe Admin::ThemesController do
|
|||||||
|
|
||||||
json = response.parsed_body
|
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 }
|
theme_json = json["themes"].find { |t| t["id"] == theme.id }
|
||||||
expect(theme_json["theme_fields"].length).to eq(2)
|
expect(theme_json["theme_fields"].length).to eq(2)
|
||||||
expect(theme_json["remote_theme"]["remote_version"]).to eq("7")
|
expect(theme_json["remote_theme"]["remote_version"]).to eq("7")
|
||||||
|
Loading…
Reference in New Issue
Block a user