From 2a49757f35b1f503624cc2cfc44b01d8ba45519c Mon Sep 17 00:00:00 2001 From: Kris Date: Sun, 20 Aug 2023 21:34:12 -0400 Subject: [PATCH] UX: update `/new` toggle styles, class names (#23154) * Minor style adjustments * Removes "all" count because it's redundant to the count on New * Updates generic class names with -- modifier to follow BEM and help avoid class name collisions * Hides the toggle when bulk select is enabled (the UI ends up being too busy) --- .../new-list-header-controls-wrapper.js | 6 +++--- .../discourse/app/components/topic-list.js | 6 +++--- .../list/new-list-header-controls.hbr | 8 +++---- .../topic-list-header-column.hbr | 12 ++++++----- .../list/new-list-header-controls.js | 10 --------- .../app/templates/mobile/discovery/topics.hbs | 19 +++++++++-------- .../discourse/app/templates/tag/show.hbs | 21 +++++++++++-------- .../stylesheets/desktop/topic-list.scss | 5 +++-- spec/system/new_topic_list_spec.rb | 18 ---------------- .../components/new_topic_list_toggle.rb | 6 +++--- 10 files changed, 45 insertions(+), 66 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/new-list-header-controls-wrapper.js b/app/assets/javascripts/discourse/app/components/new-list-header-controls-wrapper.js index 68a6b7b7df8..ff2cc7d27bf 100644 --- a/app/assets/javascripts/discourse/app/components/new-list-header-controls-wrapper.js +++ b/app/assets/javascripts/discourse/app/components/new-list-header-controls-wrapper.js @@ -3,11 +3,11 @@ import Component from "@glimmer/component"; export default class NewListHeaderControlsWrapper extends Component { click(e) { const target = e.target; - if (target.closest("button.topics-replies-toggle.all")) { + if (target.closest("button.topics-replies-toggle.--all")) { this.args.changeNewListSubset(null); - } else if (target.closest("button.topics-replies-toggle.topics")) { + } else if (target.closest("button.topics-replies-toggle.--topics")) { this.args.changeNewListSubset("topics"); - } else if (target.closest("button.topics-replies-toggle.replies")) { + } else if (target.closest("button.topics-replies-toggle.--replies")) { this.args.changeNewListSubset("replies"); } } diff --git a/app/assets/javascripts/discourse/app/components/topic-list.js b/app/assets/javascripts/discourse/app/components/topic-list.js index 5a2f6b1078a..e6f5cb88fcb 100644 --- a/app/assets/javascripts/discourse/app/components/topic-list.js +++ b/app/assets/javascripts/discourse/app/components/topic-list.js @@ -186,11 +186,11 @@ export default Component.extend(LoadMore, { }); onClick("button.topics-replies-toggle", (element) => { - if (element.classList.contains("all")) { + if (element.classList.contains("--all")) { this.changeNewListSubset(null); - } else if (element.classList.contains("topics")) { + } else if (element.classList.contains("--topics")) { this.changeNewListSubset("topics"); - } else if (element.classList.contains("replies")) { + } else if (element.classList.contains("--replies")) { this.changeNewListSubset("replies"); } this.rerender(); diff --git a/app/assets/javascripts/discourse/app/raw-templates/list/new-list-header-controls.hbr b/app/assets/javascripts/discourse/app/raw-templates/list/new-list-header-controls.hbr index 86c944165f6..9757caf8c30 100644 --- a/app/assets/javascripts/discourse/app/raw-templates/list/new-list-header-controls.hbr +++ b/app/assets/javascripts/discourse/app/raw-templates/list/new-list-header-controls.hbr @@ -1,13 +1,13 @@ {{#if view.staticLabel}} {{view.staticLabel}} {{else}} - - - {{/if}} diff --git a/app/assets/javascripts/discourse/app/raw-templates/topic-list-header-column.hbr b/app/assets/javascripts/discourse/app/raw-templates/topic-list-header-column.hbr index 60176b0c627..59f374c333b 100644 --- a/app/assets/javascripts/discourse/app/raw-templates/topic-list-header-column.hbr +++ b/app/assets/javascripts/discourse/app/raw-templates/topic-list-header-column.hbr @@ -13,11 +13,13 @@ {{/if ~}} {{/if ~}} - {{~#if view.showTopicsAndRepliesToggle}} - {{raw "list/new-list-header-controls" current=newListSubset newRepliesCount=newRepliesCount newTopicsCount=newTopicsCount}} - {{else}} - {{view.localizedName}} - {{/if ~}} + {{~#unless bulkSelectEnabled}} + {{~#if view.showTopicsAndRepliesToggle}} + {{raw "list/new-list-header-controls" current=newListSubset newRepliesCount=newRepliesCount newTopicsCount=newTopicsCount}} + {{else}} + {{view.localizedName}} + {{/if ~}} + {{/unless ~}} {{~#if view.isSorting}} {{d-icon view.sortIcon}} {{/if ~}} diff --git a/app/assets/javascripts/discourse/app/raw-views/list/new-list-header-controls.js b/app/assets/javascripts/discourse/app/raw-views/list/new-list-header-controls.js index 541d94759ba..7a6a84d3e8d 100644 --- a/app/assets/javascripts/discourse/app/raw-views/list/new-list-header-controls.js +++ b/app/assets/javascripts/discourse/app/raw-views/list/new-list-header-controls.js @@ -18,16 +18,6 @@ export default EmberObject.extend({ return !this.topicsActive && !this.repliesActive; }, - @discourseComputed - allButtonLabel() { - const count = this.newRepliesCount + this.newTopicsCount; - if (count > 0) { - return I18n.t("filters.new.all_with_count", { count }); - } else { - return I18n.t("filters.new.all"); - } - }, - @discourseComputed repliesButtonLabel() { if (this.newRepliesCount > 0) { diff --git a/app/assets/javascripts/discourse/app/templates/mobile/discovery/topics.hbs b/app/assets/javascripts/discourse/app/templates/mobile/discovery/topics.hbs index f8e33f7bca1..d3d51bc9749 100644 --- a/app/assets/javascripts/discourse/app/templates/mobile/discovery/topics.hbs +++ b/app/assets/javascripts/discourse/app/templates/mobile/discovery/topics.hbs @@ -39,15 +39,16 @@ {{/if}} {{/if}} - - {{#if this.showTopicsAndRepliesToggle}} - - {{/if}} + {{#unless this.bulkSelectEnabled}} + {{#if this.showTopicsAndRepliesToggle}} + + {{/if}} + {{/unless}} {{#if this.hasTopics}} {{/if}} {{/if}} - - {{#if (and this.showTopicsAndRepliesToggle this.site.mobileView)}} - - {{/if}} + {{#unless this.bulkSelectEnabled}} + {{#if + (and this.showTopicsAndRepliesToggle this.site.mobileView) + }} + + {{/if}} + {{/unless}} {{#if this.list.topics}}