Skip to content

Commit

Permalink
UX: update /new toggle styles, class names (#23154)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
awesomerobot committed Aug 21, 2023
1 parent b03c26e commit 2a49757
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
Expand Down
6 changes: 3 additions & 3 deletions app/assets/javascripts/discourse/app/components/topic-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{{#if view.staticLabel}}
<span class="static-label">{{view.staticLabel}}</span>
{{else}}
<button class="topics-replies-toggle all{{#if view.allActive}} active{{/if}}">
{{view.allButtonLabel}}
<button class="topics-replies-toggle --all{{#if view.allActive}} active{{/if}}">
{{i18n "filters.new.all"}}
</button>
<button class="topics-replies-toggle topics{{#if view.topicsActive}} active{{/if}}">
<button class="topics-replies-toggle --topics{{#if view.topicsActive}} active{{/if}}">
{{view.topicsButtonLabel}}
</button>
<button class="topics-replies-toggle replies{{#if view.repliesActive}} active{{/if}}">
<button class="topics-replies-toggle --replies{{#if view.repliesActive}} active{{/if}}">
{{view.repliesButtonLabel}}
</button>
{{/if}}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
</span>
{{/if ~}}
{{/if ~}}
{{~#if view.showTopicsAndRepliesToggle}}
{{raw "list/new-list-header-controls" current=newListSubset newRepliesCount=newRepliesCount newTopicsCount=newTopicsCount}}
{{else}}
<span>{{view.localizedName}}</span>
{{/if ~}}
{{~#unless bulkSelectEnabled}}
{{~#if view.showTopicsAndRepliesToggle}}
{{raw "list/new-list-header-controls" current=newListSubset newRepliesCount=newRepliesCount newTopicsCount=newTopicsCount}}
{{else}}
<span>{{view.localizedName}}</span>
{{/if ~}}
{{/unless ~}}
{{~#if view.isSorting}}
{{d-icon view.sortIcon}}
{{/if ~}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@
</a>
{{/if}}
{{/if}}

{{#if this.showTopicsAndRepliesToggle}}
<NewListHeaderControlsWrapper
@current={{this.model.params.subset}}
@newRepliesCount={{this.newRepliesCount}}
@newTopicsCount={{this.newTopicsCount}}
@changeNewListSubset={{route-action "changeNewListSubset"}}
/>
{{/if}}
{{#unless this.bulkSelectEnabled}}
{{#if this.showTopicsAndRepliesToggle}}
<NewListHeaderControlsWrapper
@current={{this.model.params.subset}}
@newRepliesCount={{this.newRepliesCount}}
@newTopicsCount={{this.newTopicsCount}}
@changeNewListSubset={{route-action "changeNewListSubset"}}
/>
{{/if}}
{{/unless}}
{{#if this.hasTopics}}
<TopicList
@ascending={{this.ascending}}
Expand Down
21 changes: 12 additions & 9 deletions app/assets/javascripts/discourse/app/templates/tag/show.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,18 @@
</div>
{{/if}}
{{/if}}

{{#if (and this.showTopicsAndRepliesToggle this.site.mobileView)}}
<NewListHeaderControlsWrapper
@current={{this.subset}}
@newRepliesCount={{this.newRepliesCount}}
@newTopicsCount={{this.newTopicsCount}}
@changeNewListSubset={{action "changeNewListSubset"}}
/>
{{/if}}
{{#unless this.bulkSelectEnabled}}
{{#if
(and this.showTopicsAndRepliesToggle this.site.mobileView)
}}
<NewListHeaderControlsWrapper
@current={{this.subset}}
@newRepliesCount={{this.newRepliesCount}}
@newTopicsCount={{this.newTopicsCount}}
@changeNewListSubset={{action "changeNewListSubset"}}
/>
{{/if}}
{{/unless}}
{{#if this.list.topics}}
<TopicList
@topics={{this.list.topics}}
Expand Down
5 changes: 3 additions & 2 deletions app/assets/stylesheets/desktop/topic-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

button.bulk-select {
padding: 0;
margin-right: 0.5em;
line-height: var(--line-height-large);
}

Expand All @@ -59,8 +60,8 @@
background: none;
border: none;
line-height: var(--line-height-large);
min-height: 30px;

padding-left: 0.5em;
padding-right: 0.5em;
&.active {
background: var(--quaternary);
color: var(--secondary);
Expand Down
18 changes: 0 additions & 18 deletions spec/system/new_topic_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
new_topic_with_tag,
].each { |topic| expect(topic_list).to have_topic(topic) }

expect(tabs_toggle.all_tab).to have_count(6)
expect(tabs_toggle.replies_tab).to have_count(3)
expect(tabs_toggle.topics_tab).to have_count(3)

Expand Down Expand Up @@ -124,7 +123,6 @@
expect(tabs_toggle.replies_tab).to be_inactive
expect(tabs_toggle.topics_tab).to be_active

expect(tabs_toggle.all_tab).to have_count(6)
expect(tabs_toggle.replies_tab).to have_count(3)
expect(tabs_toggle.topics_tab).to have_count(3)

Expand All @@ -144,7 +142,6 @@
expect(tabs_toggle.replies_tab).to be_active
expect(tabs_toggle.topics_tab).to be_inactive

expect(tabs_toggle.all_tab).to have_count(6)
expect(tabs_toggle.replies_tab).to have_count(3)
expect(tabs_toggle.topics_tab).to have_count(3)

Expand All @@ -170,19 +167,16 @@
it "live-updates the counts shown on the tabs" do
visit("/new")

expect(tabs_toggle.all_tab).to have_count(6)
expect(tabs_toggle.replies_tab).to have_count(3)
expect(tabs_toggle.topics_tab).to have_count(3)

TopicUser.update_last_read(user, new_reply_in_category.id, 2, 1, 1)

expect(tabs_toggle.all_tab).to have_count(5)
expect(tabs_toggle.replies_tab).to have_count(2)
expect(tabs_toggle.topics_tab).to have_count(3)

TopicUser.update_last_read(user, new_topic.id, 1, 1, 1)

expect(tabs_toggle.all_tab).to have_count(4)
expect(tabs_toggle.replies_tab).to have_count(2)
expect(tabs_toggle.topics_tab).to have_count(2)
end
Expand All @@ -198,7 +192,6 @@
expect(tabs_toggle.replies_tab).to be_inactive
expect(tabs_toggle.topics_tab).to be_inactive

expect(tabs_toggle.all_tab).to have_count(2)
expect(tabs_toggle.replies_tab).to have_count(1)
expect(tabs_toggle.topics_tab).to have_count(1)
end
Expand All @@ -214,7 +207,6 @@
expect(tabs_toggle.replies_tab).to be_inactive
expect(tabs_toggle.topics_tab).to be_active

expect(tabs_toggle.all_tab).to have_count(2)
expect(tabs_toggle.replies_tab).to have_count(1)
expect(tabs_toggle.topics_tab).to have_count(1)

Expand All @@ -234,7 +226,6 @@
expect(tabs_toggle.replies_tab).to be_active
expect(tabs_toggle.topics_tab).to be_inactive

expect(tabs_toggle.all_tab).to have_count(2)
expect(tabs_toggle.replies_tab).to have_count(1)
expect(tabs_toggle.topics_tab).to have_count(1)

Expand Down Expand Up @@ -262,13 +253,11 @@

visit("/c/#{category.slug}/#{category.id}/l/new")

expect(tabs_toggle.all_tab).to have_count(3)
expect(tabs_toggle.replies_tab).to have_count(1)
expect(tabs_toggle.topics_tab).to have_count(2)

TopicUser.update_last_read(user, new_topic_in_category.id, 1, 1, 1)

expect(tabs_toggle.all_tab).to have_count(2)
expect(tabs_toggle.replies_tab).to have_count(1)
expect(tabs_toggle.topics_tab).to have_count(1)
end
Expand All @@ -286,7 +275,6 @@
expect(tabs_toggle.replies_tab).to be_inactive
expect(tabs_toggle.topics_tab).to be_inactive

expect(tabs_toggle.all_tab).to have_count(2)
expect(tabs_toggle.replies_tab).to have_count(1)
expect(tabs_toggle.topics_tab).to have_count(1)
end
Expand All @@ -302,7 +290,6 @@
expect(tabs_toggle.replies_tab).to be_inactive
expect(tabs_toggle.topics_tab).to be_active

expect(tabs_toggle.all_tab).to have_count(2)
expect(tabs_toggle.replies_tab).to have_count(1)
expect(tabs_toggle.topics_tab).to have_count(1)

Expand All @@ -321,7 +308,6 @@
expect(tabs_toggle.replies_tab).to be_active
expect(tabs_toggle.topics_tab).to be_inactive

expect(tabs_toggle.all_tab).to have_count(2)
expect(tabs_toggle.replies_tab).to have_count(1)
expect(tabs_toggle.topics_tab).to have_count(1)

Expand All @@ -347,13 +333,11 @@

visit("/tag/#{tag.name}/l/new")

expect(tabs_toggle.all_tab).to have_count(3)
expect(tabs_toggle.replies_tab).to have_count(1)
expect(tabs_toggle.topics_tab).to have_count(2)

TopicUser.update_last_read(user, new_topic_with_tag.id, 1, 1, 1)

expect(tabs_toggle.all_tab).to have_count(2)
expect(tabs_toggle.replies_tab).to have_count(1)
expect(tabs_toggle.topics_tab).to have_count(1)
end
Expand Down Expand Up @@ -389,7 +373,6 @@
expect(tabs_toggle.replies_tab).to be_visible
expect(tabs_toggle.topics_tab).to be_visible

expect(tabs_toggle.all_tab).to have_count(3)
expect(tabs_toggle.replies_tab).to have_count(3)
expect(tabs_toggle.topics_tab).to have_count(0)
end
Expand All @@ -411,7 +394,6 @@
expect(tabs_toggle.replies_tab).to be_visible
expect(tabs_toggle.topics_tab).to be_visible

expect(tabs_toggle.all_tab).to have_count(3)
expect(tabs_toggle.replies_tab).to have_count(0)
expect(tabs_toggle.topics_tab).to have_count(3)
end
Expand Down
6 changes: 3 additions & 3 deletions spec/system/page_objects/components/new_topic_list_toggle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ module Components
class NewTopicListToggle < PageObjects::Components::Base
COMMON_SELECTOR = ".topics-replies-toggle"

ALL_SELECTOR = "#{COMMON_SELECTOR}.all"
REPLIES_SELECTOR = "#{COMMON_SELECTOR}.replies"
TOPICS_SELECTOR = "#{COMMON_SELECTOR}.topics"
ALL_SELECTOR = "#{COMMON_SELECTOR}.--all"
REPLIES_SELECTOR = "#{COMMON_SELECTOR}.--replies"
TOPICS_SELECTOR = "#{COMMON_SELECTOR}.--topics"

def not_rendered?
has_no_css?(COMMON_SELECTOR)
Expand Down

0 comments on commit 2a49757

Please sign in to comment.