DEV: Setup categories section in sidebar for future work (#16733)

This commit is contained in:
Alan Guo Xiang Tan 2022-05-13 09:35:15 +08:00 committed by GitHub
parent ab9433569a
commit 2cc9f0e7d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 56 additions and 3 deletions

View File

@ -0,0 +1,3 @@
import GlimmerComponent from "discourse/components/glimmer";
export default class SidebarCategoriesSection extends GlimmerComponent {}

View File

@ -2,6 +2,7 @@
<div class="sidebar-wrapper">
<div class="sidebar-container">
<Sidebar::TopicsSection />
<Sidebar::CategoriesSection />
</div>
</div>
{{/if}}

View File

@ -0,0 +1,7 @@
<Sidebar::Section
@sectionName="categories"
@headerRoute="discovery.categories"
@headerLinkText={{i18n "sidebar.sections.categories.header_link_text"}}
@headerLinkTitle={{i18n "sidebar.sections.categories.header_link_title"}} >
</Sidebar::Section>

View File

@ -0,0 +1,26 @@
import { click, currentURL, visit } from "@ember/test-helpers";
import {
acceptance,
conditionalTest,
} from "discourse/tests/helpers/qunit-helpers";
import { isLegacyEmber } from "discourse-common/config/environment";
acceptance("Sidebar - Categories Section", function (needs) {
needs.user({ experimental_sidebar_enabled: true });
conditionalTest(
"clicking on section header link",
!isLegacyEmber(),
async function (assert) {
await visit("/t/280");
await click(".sidebar-section-categories .sidebar-section-header-link");
assert.strictEqual(
currentURL(),
"/categories",
"it should transition to the categories page"
);
}
);
});

View File

@ -64,15 +64,24 @@ acceptance("Sidebar - Topics Section", function (needs) {
async function (assert) {
await visit("/");
assert.ok(exists(".sidebar-section-content"), "shows content section");
assert.ok(
exists(".sidebar-section-topics .sidebar-section-content"),
"shows content section"
);
await click(".sidebar-section-topics .sidebar-section-header-caret");
assert.ok(!exists(".sidebar-section-content"), "hides content section");
assert.ok(
!exists(".sidebar-section-topics .sidebar-section-content"),
"hides content section"
);
await click(".sidebar-section-topics .sidebar-section-header-caret");
assert.ok(exists(".sidebar-section-content"), "shows content section");
assert.ok(
exists(".sidebar-section-topics .sidebar-section-content"),
"shows content section"
);
}
);

View File

@ -40,6 +40,10 @@
justify-content: flex-end;
}
.sidebar-section-wrapper {
margin-bottom: 1em;
}
.sidebar-section-header {
display: flex;
text-transform: uppercase;

View File

@ -4035,6 +4035,9 @@ en:
unread_count: "%{count} unread"
new_count: "%{count} new"
sections:
categories:
header_link_title: "all categories"
header_link_text: "Categories"
topics:
header_link_title: "home"
header_link_text: "Topics"