Skip to content

Commit 4dd6c82

Browse files
keegangeorgejancernik
authored andcommitted
UX: Improvements to posts route (discourse#30968)
This update makes some small improvements to the posts route front-end. Specifically, it adds a title to the page, and it improves the positioning of expand/collapse caret.
1 parent 4f38d0a commit 4dd6c82

File tree

5 files changed

+56
-5
lines changed

5 files changed

+56
-5
lines changed

app/assets/javascripts/discourse/app/templates/posts.gjs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { action } from "@ember/object";
33
import RouteTemplate from "ember-route-template";
44
import PostList from "discourse/components/post-list";
55
import Posts from "discourse/models/posts";
6+
import { i18n } from "discourse-i18n";
67

78
export default RouteTemplate(
89
class extends Component {
@@ -15,11 +16,14 @@ export default RouteTemplate(
1516
}
1617

1718
<template>
18-
<PostList
19-
@posts={{@model}}
20-
@fetchMorePosts={{this.loadMorePosts}}
21-
@titlePath="topic_html_title"
22-
/>
19+
<section class="posts-page">
20+
<h2 class="posts-page__title">{{i18n "post_list.title"}}</h2>
21+
<PostList
22+
@posts={{@model}}
23+
@fetchMorePosts={{this.loadMorePosts}}
24+
@titlePath="topic_html_title"
25+
/>
26+
</section>
2327
</template>
2428
}
2529
);

app/assets/stylesheets/common/components/post-list.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@
3434
}
3535
}
3636

37+
.expand-item,
38+
.collapse-item {
39+
padding: 0;
40+
margin-right: 0.75rem;
41+
margin-top: 0.15rem;
42+
}
43+
3744
.stream-topic-title {
3845
overflow-wrap: anywhere;
3946
}

config/locales/client.en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3763,6 +3763,7 @@ en:
37633763
deleted_by_author_simple: "(topic deleted by author)"
37643764

37653765
post_list:
3766+
title: "Latest posts"
37663767
empty: "There are no posts"
37673768
aria_post_number: "%{title} - post #%{postNumber}"
37683769

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# frozen_string_literal: true
2+
3+
module PageObjects
4+
module Pages
5+
class Posts < PageObjects::Pages::Base
6+
POSTS_PAGE_SELECTOR = ".posts-page"
7+
8+
def visit
9+
page.visit("/posts")
10+
self
11+
end
12+
13+
def has_page_title?
14+
page.find("#{POSTS_PAGE_SELECTOR} .posts-page__title")
15+
end
16+
17+
def has_posts?(count)
18+
page.has_css?("#{POSTS_PAGE_SELECTOR} .post-list .post-list-item", count: count)
19+
end
20+
end
21+
end
22+
end

spec/system/posts_page_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
describe "Posts page", type: :system do
4+
fab!(:post)
5+
fab!(:post_2) { Fabricate(:post) }
6+
fab!(:post_3) { Fabricate(:post) }
7+
fab!(:user)
8+
let(:posts_page) { PageObjects::Pages::Posts.new }
9+
10+
before { sign_in(user) }
11+
12+
it "renders the posts page with posts" do
13+
posts_page.visit
14+
expect(posts_page).to have_page_title
15+
expect(posts_page).to have_posts(3)
16+
end
17+
end

0 commit comments

Comments
 (0)