Skip to content

A platform for community discussion. Free, open, simple.

UX: Improve default badge positioning on admin themes/colors index (#34456)

Alan Guo Xiang Tana8ed5b19f951
diff --git a/app/assets/javascripts/admin/addon/components/color-palette-list-item.gjs b/app/assets/javascripts/admin/addon/components/color-palette-list-item.gjs
index f0a8b1d4805..725935ea714 100644
--- a/app/assets/javascripts/admin/addon/components/color-palette-list-item.gjs
+++ b/app/assets/javascripts/admin/addon/components/color-palette-list-item.gjs
@@ -3,7 +3,7 @@ import { tracked } from "@glimmer/tracking";
import { array, fn } from "@ember/helper";
import { action } from "@ember/object";
import { LinkTo } from "@ember/routing";
-import { not, or } from "truth-helpers";
+import { not } from "truth-helpers";
import ColorPalettePreview from "discourse/components/color-palette-preview";
import DButton from "discourse/components/d-button";
import DropdownMenu from "discourse/components/dropdown-menu";
@@ -69,26 +69,6 @@ export default class ColorPaletteListItem extends Component {
);
}
- get defaultBadgeTitle() {
- if (this.isDefaultLight && this.isDefaultDark) {
- return i18n("admin.customize.colors.default_both_badge.title");
- }
- if (this.isDefaultLight) {
- return i18n("admin.customize.colors.default_light_badge.title");
- }
- return i18n("admin.customize.colors.default_dark_badge.title");
- }
-
- get defaultBadgeText() {
- if (this.isDefaultLight && this.isDefaultDark) {
- return i18n("admin.customize.colors.default_both_badge.text");
- }
- if (this.isDefaultLight) {
- return i18n("admin.customize.colors.default_light_badge.text");
- }
- return i18n("admin.customize.colors.default_dark_badge.text");
- }
-
@bind
setAsDefaultLabel(mode) {
const themeName = this.args.defaultTheme?.name || "Default";
@@ -140,6 +120,28 @@ export default class ColorPaletteListItem extends Component {
</div>
<div class="color-palette__badges">
+ {{#if this.isDefaultLight}}
+ <span
+ title={{i18n
+ "admin.customize.colors.default_light_badge.title"
+ }}
+ class="theme-card__badge --default"
+ >
+ {{icon "sun"}}
+ {{i18n "admin.customize.colors.default_light_badge.text"}}
+ </span>
+ {{/if}}
+
+ {{#if this.isDefaultDark}}
+ <span
+ title={{i18n "admin.customize.colors.default_dark_badge.title"}}
+ class="theme-card__badge --default"
+ >
+ {{icon "moon"}}
+ {{i18n "admin.customize.colors.default_dark_badge.text"}}
+ </span>
+ {{/if}}
+
{{#if @scheme.user_selectable}}
<span
title={{i18n "admin.customize.theme.user_selectable"}}
@@ -150,15 +152,6 @@ export default class ColorPaletteListItem extends Component {
</span>
{{/if}}
</div>
-
- {{#if (or this.isDefaultLight this.isDefaultDark)}}
- <span
- title={{this.defaultBadgeTitle}}
- class="theme-card__badge --default"
- >
- {{this.defaultBadgeText}}
- </span>
- {{/if}}
</div>
<div class="color-palette__controls">
diff --git a/app/assets/javascripts/admin/addon/components/themes-grid-card.gjs b/app/assets/javascripts/admin/addon/components/themes-grid-card.gjs
index a6f5b075078..4d79e02d06b 100644
--- a/app/assets/javascripts/admin/addon/components/themes-grid-card.gjs
+++ b/app/assets/javascripts/admin/addon/components/themes-grid-card.gjs
@@ -134,14 +134,6 @@ export default class ThemeCard extends Component {
<template>
<AdminConfigAreaCard class={{this.themeCardClasses}}>
<:content>
- {{#if @theme.default}}
- <span
- class="theme-card__badge --default"
- title={{i18n "admin.customize.theme.default_theme"}}
- >
- {{i18n "admin.customize.theme.default"}}
- </span>
- {{/if}}
<div class="theme-card__image-wrapper">
{{#if @theme.screenshot_url}}
@@ -170,6 +162,14 @@ export default class ThemeCard extends Component {
{{i18n "admin.customize.theme.update_available"}}</span>
{{/if}}
+ {{#if @theme.default}}
+ <span
+ class="theme-card__badge --default"
+ title={{i18n "admin.customize.theme.default_theme"}}
+ >{{icon "paintbrush"}}
+ {{i18n "admin.customize.theme.default"}}</span>
+ {{/if}}
+
{{#if @theme.user_selectable}}
<span
title={{i18n "admin.customize.theme.user_selectable"}}
diff --git a/app/assets/stylesheets/admin/color_palettes.scss b/app/assets/stylesheets/admin/color_palettes.scss
index fddd54e465d..184b0dac2d5 100644
--- a/app/assets/stylesheets/admin/color_palettes.scss
+++ b/app/assets/stylesheets/admin/color_palettes.scss
@@ -62,6 +62,11 @@
}
&__badges {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: flex-start;
+ gap: var(--space-1);
+ margin: var(--space-1) 0;
min-height: 2rem;
}
diff --git a/app/assets/stylesheets/common/components/theme-card.scss b/app/assets/stylesheets/common/components/theme-card.scss
index 91a304fd4f3..45cdaa9a64a 100644
--- a/app/assets/stylesheets/common/components/theme-card.scss
+++ b/app/assets/stylesheets/common/components/theme-card.scss
@@ -202,16 +202,6 @@
height: 0.75em;
color: var(--primary-high);
}
-
- &.--default {
- background-color: var(--tertiary);
- color: var(--secondary);
- position: absolute;
- right: 8px;
- top: 8px;
- font-size: var(--font-down-3);
- text-transform: uppercase;
- }
}
.admin-config-area-card__header-action {
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index da03cb3ebc1..d5c84cb39a9 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -6918,7 +6918,7 @@ en:
extra_files_upload: "Export theme to view these files."
extra_files_remote: "Export theme or check the git repository to view these files."
preview: "Preview"
- default: "Default"
+ default: "Default theme"
settings_editor: "Settings Editor"
show_advanced: "Show advanced"
is_default: "Theme is enabled by default"
@@ -7157,9 +7157,6 @@ en:
default_dark_badge:
text: "Default dark"
title: "Default dark color palette"
- default_both_badge:
- text: "Default light and dark"
- title: "Default light and dark color palette"
system_palette: "This is a built-in color palette, it cannot be edited or deleted."
back_to_colors: "Back to color palettes"
long_title: "Color palettes"
diff --git a/spec/system/admin_color_palettes_features_spec.rb b/spec/system/admin_color_palettes_features_spec.rb
index ba5b8a5c385..f64ca3e3333 100644
--- a/spec/system/admin_color_palettes_features_spec.rb
+++ b/spec/system/admin_color_palettes_features_spec.rb
@@ -161,7 +161,7 @@ describe "Admin Color Palettes Features", type: :system do
within("[data-palette-id='#{regular_palette.id}']") do
expect(page).to have_css(
".theme-card__badge.--default",
- text: I18n.t("admin_js.admin.customize.colors.default_light_badge.text").upcase,
+ text: I18n.t("admin_js.admin.customize.colors.default_light_badge.text"),
)
end
@@ -179,7 +179,7 @@ describe "Admin Color Palettes Features", type: :system do
within("[data-palette-id='#{regular_palette.id}']") do
expect(page).to have_css(
".theme-card__badge.--default",
- text: I18n.t("admin_js.admin.customize.colors.default_both_badge.text").upcase,
+ text: I18n.t("admin_js.admin.customize.colors.default_dark_badge.text"),
)
end
end
diff --git a/spec/system/admin_customize_themes_config_area_spec.rb b/spec/system/admin_customize_themes_config_area_spec.rb
index f1948e8aab5..edd1fce2cab 100644
--- a/spec/system/admin_customize_themes_config_area_spec.rb
+++ b/spec/system/admin_customize_themes_config_area_spec.rb
@@ -38,11 +38,13 @@ describe "Admin Customize Themes Config Area Page", type: :system do
it "allows to mark theme as default" do
config_area.visit
- expect(config_area).to have_badge(foundation_theme, "--default")
- expect(config_area).to have_no_badge(theme_2, "--default")
+ expect(config_area).to have_default_badge(foundation_theme)
+ expect(config_area).to have_no_default_badge(theme_2)
+
config_area.mark_as_default(theme_2)
- expect(config_area).to have_badge(theme_2, "--default")
- expect(config_area).to have_no_badge(foundation_theme, "--default")
+
+ expect(config_area).to have_default_badge(theme_2)
+ expect(config_area).to have_no_default_badge(foundation_theme)
end
it "allows to make theme selectable by users" do
diff --git a/spec/system/page_objects/pages/admin_customize_themes_config_area.rb b/spec/system/page_objects/pages/admin_customize_themes_config_area.rb
index e0fead783d8..a75f12c87f8 100644
--- a/spec/system/page_objects/pages/admin_customize_themes_config_area.rb
+++ b/spec/system/page_objects/pages/admin_customize_themes_config_area.rb
@@ -25,8 +25,16 @@ module PageObjects
find(".set-default").click
end
- def has_badge?(theme, badge)
- find_theme_card(theme).has_css?(".theme-card__badge.#{badge}")
+ def has_default_badge?(theme)
+ has_badge?(theme, "--default", text: I18n.t("admin_js.admin.customize.theme.default"))
+ end
+
+ def has_no_default_badge?(theme)
+ has_no_badge?(theme, "--default")
+ end
+
+ def has_badge?(theme, badge, **kwargs)
+ find_theme_card(theme).has_css?(".theme-card__badge.#{badge}", **kwargs)
end
def has_no_badge?(theme, badge)