UX: Move About and FAQ links into secondary section in More... dropdown (#17793)

This commit does not change any behaviour of the links and is simply
changing the positions of the links being displayed.
This commit is contained in:
Alan Guo Xiang Tan 2022-08-04 13:41:08 +08:00 committed by GitHub
parent fc421ca41e
commit e09fd7cde2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 65 additions and 45 deletions

View File

@ -24,25 +24,21 @@ const MAIN_SECTION_LINKS = [
const ADMIN_MAIN_SECTION_LINKS = [AdminSectionLink]; const ADMIN_MAIN_SECTION_LINKS = [AdminSectionLink];
const MORE_SECTION_LINKS = [ const MORE_SECTION_LINKS = [GroupsSectionLink, UsersSectionLink];
GroupsSectionLink, const MORE_SECONDARY_SECTION_LINKS = [AboutSectionLink, FAQSectionLink];
UsersSectionLink,
AboutSectionLink,
FAQSectionLink,
];
export default class SidebarCommunitySection extends GlimmerComponent { export default class SidebarCommunitySection extends GlimmerComponent {
@service router; @service router;
moreSectionLinks = [...MORE_SECTION_LINKS, ...customSectionLinks].map( moreSectionLinks = [...MORE_SECTION_LINKS, ...customSectionLinks].map(
(sectionLinkClass) => { (sectionLinkClass) => {
return new sectionLinkClass({ return this.#initializeSectionLink(sectionLinkClass);
topicTrackingState: this.topicTrackingState, }
currentUser: this.currentUser, );
appEvents: this.appEvents,
router: this.router, moreSecondarySectionLinks = MORE_SECONDARY_SECTION_LINKS.map(
siteSettings: this.siteSettings, (sectionLinkClass) => {
}); return this.#initializeSectionLink(sectionLinkClass);
} }
); );
@ -51,11 +47,7 @@ export default class SidebarCommunitySection extends GlimmerComponent {
: [...MAIN_SECTION_LINKS]; : [...MAIN_SECTION_LINKS];
sectionLinks = this.#mainSectionLinks.map((sectionLinkClass) => { sectionLinks = this.#mainSectionLinks.map((sectionLinkClass) => {
return new sectionLinkClass({ return this.#initializeSectionLink(sectionLinkClass);
topicTrackingState: this.topicTrackingState,
currentUser: this.currentUser,
appEvents: this.appEvents,
});
}); });
willDestroy() { willDestroy() {
@ -80,4 +72,14 @@ export default class SidebarCommunitySection extends GlimmerComponent {
getOwner(this).lookup("controller:composer").open(composerArgs); getOwner(this).lookup("controller:composer").open(composerArgs);
}); });
} }
#initializeSectionLink(sectionLinkClass) {
return new sectionLinkClass({
topicTrackingState: this.topicTrackingState,
currentUser: this.currentUser,
appEvents: this.appEvents,
router: this.router,
siteSettings: this.siteSettings,
});
}
} }

View File

@ -24,14 +24,26 @@ export default class SidebarMoreSectionLinks extends GlimmerComponent {
get sectionLinks() { get sectionLinks() {
if (this.activeSectionLink) { if (this.activeSectionLink) {
return this.args.sectionLinks.filter((sectionLink) => { return this.#filterActiveSectionLink(this.args.sectionLinks);
return sectionLink.name !== this.activeSectionLink.name;
});
} else { } else {
return this.args.sectionLinks; return this.args.sectionLinks;
} }
} }
get secondarySectionLinks() {
if (this.activeSectionLink) {
return this.#filterActiveSectionLink(this.args.secondarySectionLinks);
} else {
return this.args.secondarySectionLinks;
}
}
#filterActiveSectionLink(sectionLinks) {
return sectionLinks.filter((sectionLink) => {
return sectionLink.name !== this.activeSectionLink.name;
});
}
@bind @bind
closeDetails(event) { closeDetails(event) {
if (this.shouldDisplaySectionLinks) { if (this.shouldDisplaySectionLinks) {

View File

@ -22,5 +22,5 @@
@models={{sectionLink.models}} /> @models={{sectionLink.models}} />
{{/each}} {{/each}}
<Sidebar::MoreSectionLinks @sectionLinks={{this.moreSectionLinks}} /> <Sidebar::MoreSectionLinks @sectionLinks={{this.moreSectionLinks}} @secondarySectionLinks={{this.moreSecondarySectionLinks}} />
</Sidebar::Section> </Sidebar::Section>

View File

@ -0,0 +1,11 @@
<Sidebar::SectionLink
@linkName={{@sectionLink.name}}
@route={{@sectionLink.route}}
@href={{@sectionLink.href}}
@query={{@sectionLink.query}}
@title={{@sectionLink.title}}
@content={{@sectionLink.text}}
@currentWhen={{@sectionLink.currentWhen}}
@badgeText={{@sectionLink.badgeText}}
@model={{@sectionLink.model}}
@models={{@sectionLink.models}} />

View File

@ -1,14 +1,5 @@
{{#if this.activeSectionLink}} {{#if this.activeSectionLink}}
<Sidebar::SectionLink <Sidebar::MoreSectionLink @sectionLink={{this.activeSectionLink}} />
@linkName={{this.activeSectionLink.name}}
@route={{this.activeSectionLink.route}}
@query={{this.activeSectionLink.query}}
@title={{this.activeSectionLink.title}}
@content={{this.activeSectionLink.text}}
@currentWhen={{this.activeSectionLink.currentWhen}}
@badgeText={{this.activeSectionLink.badgeText}}
@model={{this.activeSectionLink.model}}
@models={{this.activeSectionLink.models}} />
{{/if}} {{/if}}
<details class="sidebar-more-section-links-details" {{on "toggle" this.toggleSectionLinks}}> <details class="sidebar-more-section-links-details" {{on "toggle" this.toggleSectionLinks}}>
@ -21,19 +12,19 @@
{{did-insert this.registerClickListener}} {{did-insert this.registerClickListener}}
{{will-destroy this.unregisterClickListener}} > {{will-destroy this.unregisterClickListener}} >
{{#each this.sectionLinks as |sectionLink|}} <div class="sidebar-more-section-links-details-content-main">
<Sidebar::SectionLink {{#each this.sectionLinks as |sectionLink|}}
@linkName={{sectionLink.name}} <Sidebar::MoreSectionLink @sectionLink={{sectionLink}} />
@route={{sectionLink.route}} {{/each}}
@href={{sectionLink.href}} </div>
@query={{sectionLink.query}}
@title={{sectionLink.title}} {{#if (gt this.secondarySectionLinks.length 0)}}
@content={{sectionLink.text}} <div class="sidebar-more-section-links-details-content-secondary">
@currentWhen={{sectionLink.currentWhen}} {{#each this.secondarySectionLinks as |sectionLink|}}
@badgeText={{sectionLink.badgeText}} <Sidebar::MoreSectionLink @sectionLink={{sectionLink}} />
@model={{sectionLink.model}} {{/each}}
@models={{sectionLink.models}} /> </div>
{{/each}} {{/if}}
</div> </div>
{{/if}} {{/if}}
</details> </details>

View File

@ -36,4 +36,8 @@
margin-left: none; margin-left: none;
} }
} }
.sidebar-more-section-links-details-content-secondary {
border-top: 1.5px solid var(--primary-low);
}
} }