Skip to content

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

UX: Swap nested view post sort to nav-pills (#39425)

Mark VanLandingham3f019d253672
diff --git a/app/assets/stylesheets/common/nested-view.scss b/app/assets/stylesheets/common/nested-view.scss
index a8217b759be..fe074e0f16d 100644
--- a/app/assets/stylesheets/common/nested-view.scss
+++ b/app/assets/stylesheets/common/nested-view.scss
@@ -238,30 +238,6 @@
}
}
-// ── Sort selector ──────────────────────────────────────────────────
-.nested-sort-selector {
- display: flex;
- align-items: center;
- gap: 0.25em;
-
- &__label {
- font-size: var(--font-down-1);
- color: var(--primary-medium);
- margin-right: 0.25em;
- }
-
- &__option {
- font-size: var(--font-down-1);
- padding: 0.25em 0.5em;
- color: var(--primary-medium);
-
- &--active {
- color: var(--tertiary);
- font-weight: bold;
- }
- }
-}
-
// ── Nested post (single comment in tree) ───────────────────────────
.nested-post {
// Avatar size for the "small" PostAvatar used in nested posts.
diff --git a/frontend/discourse/app/components/nested-sort-selector.gjs b/frontend/discourse/app/components/nested-sort-selector.gjs
deleted file mode 100644
index 57abf48f98c..00000000000
--- a/frontend/discourse/app/components/nested-sort-selector.gjs
+++ /dev/null
@@ -1,46 +0,0 @@
-import { fn } from "@ember/helper";
-import DButton from "discourse/components/d-button";
-import concatClass from "discourse/helpers/concat-class";
-import { eq } from "discourse/truth-helpers";
-import { i18n } from "discourse-i18n";
-
-const NestedSortSelector = <template>
- <div
- class="nested-sort-selector"
- role="group"
- aria-label={{i18n "nested_replies.sort.label"}}
- >
- <span class="nested-sort-selector__label">{{i18n
- "nested_replies.sort.label"
- }}</span>
- <DButton
- class={{concatClass
- "btn-flat nested-sort-selector__option"
- (if (eq @current "top") "nested-sort-selector__option--active")
- }}
- aria-pressed={{if (eq @current "top") "true" "false"}}
- @action={{fn @onChange "top"}}
- @translatedLabel={{i18n "nested_replies.sort.top"}}
- />
- <DButton
- class={{concatClass
- "btn-flat nested-sort-selector__option"
- (if (eq @current "new") "nested-sort-selector__option--active")
- }}
- aria-pressed={{if (eq @current "new") "true" "false"}}
- @action={{fn @onChange "new"}}
- @translatedLabel={{i18n "nested_replies.sort.new"}}
- />
- <DButton
- class={{concatClass
- "btn-flat nested-sort-selector__option"
- (if (eq @current "old") "nested-sort-selector__option--active")
- }}
- aria-pressed={{if (eq @current "old") "true" "false"}}
- @action={{fn @onChange "old"}}
- @translatedLabel={{i18n "nested_replies.sort.old"}}
- />
- </div>
-</template>;
-
-export default NestedSortSelector;
diff --git a/frontend/discourse/app/components/nested-view.gjs b/frontend/discourse/app/components/nested.gjs
similarity index 94%
rename from frontend/discourse/app/components/nested-view.gjs
rename to frontend/discourse/app/components/nested.gjs
index 84db646c377..7c5af42559c 100644
--- a/frontend/discourse/app/components/nested-view.gjs
+++ b/frontend/discourse/app/components/nested.gjs
@@ -14,13 +14,13 @@ import getURL from "discourse/lib/get-url";
import PostStreamViewportTracker from "discourse/modifiers/post-stream-viewport-tracker";
import { gt, includes } from "discourse/truth-helpers";
import { i18n } from "discourse-i18n";
-import NestedFloatingActions from "./nested-floating-actions";
-import NestedOp from "./nested-op";
-import NestedPost from "./nested-post";
-import NestedSortSelector from "./nested-sort-selector";
-import NestedViewHeader from "./nested-view-header";
+import NestedFloatingActions from "./nested/floating-actions";
+import NestedHeader from "./nested/header";
+import NestedOp from "./nested/op";
+import NestedPost from "./nested/post";
+import NestedSortSelector from "./nested/sort-selector";
-export default class NestedView extends Component {
+export default class Nested extends Component {
@service currentUser;
@service header;
@service screenTrack;
@@ -55,7 +55,7 @@ export default class NestedView extends Component {
}}
>
- <NestedViewHeader
+ <NestedHeader
@topic={{@topic}}
@editingTopic={{@editingTopic}}
@buffered={{@buffered}}
diff --git a/frontend/discourse/app/components/nested-context-view.gjs b/frontend/discourse/app/components/nested/context-view.gjs
similarity index 95%
rename from frontend/discourse/app/components/nested-context-view.gjs
rename to frontend/discourse/app/components/nested/context-view.gjs
index ae2ab29d010..96099406add 100644
--- a/frontend/discourse/app/components/nested-context-view.gjs
+++ b/frontend/discourse/app/components/nested/context-view.gjs
@@ -10,11 +10,11 @@ import getURL from "discourse/lib/get-url";
import PostStreamViewportTracker from "discourse/modifiers/post-stream-viewport-tracker";
import { or } from "discourse/truth-helpers";
import { i18n } from "discourse-i18n";
-import NestedFloatingActions from "./nested-floating-actions";
-import NestedOp from "./nested-op";
-import NestedPost from "./nested-post";
-import NestedSortSelector from "./nested-sort-selector";
-import NestedViewHeader from "./nested-view-header";
+import NestedFloatingActions from "./floating-actions";
+import NestedHeader from "./header";
+import NestedOp from "./op";
+import NestedPost from "./post";
+import NestedSortSelector from "./sort-selector";
export default class NestedContextView extends Component {
@service currentUser;
@@ -100,7 +100,7 @@ export default class NestedContextView extends Component {
}}
>
- <NestedViewHeader
+ <NestedHeader
@topic={{@topic}}
@editingTopic={{@editingTopic}}
@buffered={{@buffered}}
diff --git a/frontend/discourse/app/components/nested-floating-actions.gjs b/frontend/discourse/app/components/nested/floating-actions.gjs
similarity index 100%
rename from frontend/discourse/app/components/nested-floating-actions.gjs
rename to frontend/discourse/app/components/nested/floating-actions.gjs
diff --git a/frontend/discourse/app/components/nested-view-header.gjs b/frontend/discourse/app/components/nested/header.gjs
similarity index 100%
rename from frontend/discourse/app/components/nested-view-header.gjs
rename to frontend/discourse/app/components/nested/header.gjs
diff --git a/frontend/discourse/app/components/nested-op.gjs b/frontend/discourse/app/components/nested/op.gjs
similarity index 100%
rename from frontend/discourse/app/components/nested-op.gjs
rename to frontend/discourse/app/components/nested/op.gjs
diff --git a/frontend/discourse/app/components/nested-post-children.gjs b/frontend/discourse/app/components/nested/post-children.gjs
similarity index 98%
rename from frontend/discourse/app/components/nested-post-children.gjs
rename to frontend/discourse/app/components/nested/post-children.gjs
index 748988ab1b5..689ac0e1d4b 100644
--- a/frontend/discourse/app/components/nested-post-children.gjs
+++ b/frontend/discourse/app/components/nested/post-children.gjs
@@ -8,8 +8,8 @@ import concatClass from "discourse/helpers/concat-class";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { i18n } from "discourse-i18n";
-import processNode from "../lib/process-node";
-import NestedPost from "./nested-post";
+import processNode from "../../lib/process-node";
+import NestedPost from "./post";
export default class NestedPostChildren extends Component {
@service appEvents;
diff --git a/frontend/discourse/app/components/nested-post.gjs b/frontend/discourse/app/components/nested/post.gjs
similarity index 99%
rename from frontend/discourse/app/components/nested-post.gjs
rename to frontend/discourse/app/components/nested/post.gjs
index 7fa7a856e5f..00ae680edb4 100644
--- a/frontend/discourse/app/components/nested-post.gjs
+++ b/frontend/discourse/app/components/nested/post.gjs
@@ -26,8 +26,8 @@ import { nativeShare } from "discourse/lib/pwa-utils";
import { clipboardCopy } from "discourse/lib/utilities";
import { and, not, or } from "discourse/truth-helpers";
import { i18n } from "discourse-i18n";
-import nestedPostUrl from "../lib/nested-post-url";
-import NestedPostChildren from "./nested-post-children";
+import nestedPostUrl from "../../lib/nested-post-url";
+import NestedPostChildren from "./post-children";
export default class NestedPost extends Component {
@service appEvents;
diff --git a/frontend/discourse/app/components/nested/sort-selector.gjs b/frontend/discourse/app/components/nested/sort-selector.gjs
new file mode 100644
index 00000000000..c5bdccb59c6
--- /dev/null
+++ b/frontend/discourse/app/components/nested/sort-selector.gjs
@@ -0,0 +1,43 @@
+import { fn } from "@ember/helper";
+import { on } from "@ember/modifier";
+import { eq } from "discourse/truth-helpers";
+import { i18n } from "discourse-i18n";
+
+const SortOption = <template>
+ <li>
+ <button
+ type="button"
+ class={{if (eq @current @value) "active"}}
+ aria-pressed={{if (eq @current @value) "true" "false"}}
+ {{on "click" (fn @onChange @value)}}
+ >{{@label}}</button>
+ </li>
+</template>;
+
+const NestedSortSelector = <template>
+ <ul
+ class="nested-sort-selector nav-pills"
+ aria-label={{i18n "nested_replies.sort.label"}}
+ >
+ <SortOption
+ @value="top"
+ @label={{i18n "nested_replies.sort.top"}}
+ @current={{@current}}
+ @onChange={{@onChange}}
+ />
+ <SortOption
+ @value="new"
+ @label={{i18n "nested_replies.sort.new"}}
+ @current={{@current}}
+ @onChange={{@onChange}}
+ />
+ <SortOption
+ @value="old"
+ @label={{i18n "nested_replies.sort.old"}}
+ @current={{@current}}
+ @onChange={{@onChange}}
+ />
+ </ul>
+</template>;
+
+export default NestedSortSelector;
diff --git a/frontend/discourse/app/templates/nested.gjs b/frontend/discourse/app/templates/nested.gjs
index 1d2a99f38b3..9056dfe2001 100644
--- a/frontend/discourse/app/templates/nested.gjs
+++ b/frontend/discourse/app/templates/nested.gjs
@@ -1,5 +1,5 @@
-import NestedContextView from "discourse/components/nested-context-view";
-import NestedView from "discourse/components/nested-view";
+import Nested from "discourse/components/nested";
+import NestedContextView from "discourse/components/nested/context-view";
import PostTextSelection from "discourse/components/post-text-selection";
export default <template>
@@ -44,7 +44,7 @@ export default <template>
@scrollAnchor={{@controller.scrollAnchor}}
/>
{{else}}
- <NestedView
+ <Nested
@topic={{@controller.topic}}
@opPost={{@controller.opPost}}
@rootNodes={{@controller.rootNodes}}
diff --git a/spec/system/page_objects/pages/nested_view.rb b/spec/system/page_objects/pages/nested_view.rb
index 400c59f4653..aa61b177508 100644
--- a/spec/system/page_objects/pages/nested_view.rb
+++ b/spec/system/page_objects/pages/nested_view.rb
@@ -155,7 +155,7 @@ module PageObjects
def has_sort_active?(sort)
has_css?(
- ".nested-sort-selector__option--active",
+ ".nested-sort-selector button.active",
text: I18n.t("js.nested_replies.sort.#{sort}"),
)
end
@@ -333,7 +333,7 @@ module PageObjects
end
def click_sort(sort)
- find(".nested-sort-selector__option", text: I18n.t("js.nested_replies.sort.#{sort}")).click
+ find(".nested-sort-selector button", text: I18n.t("js.nested_replies.sort.#{sort}")).click
self
end