FEATURE: Store sidebar section display state in local storage (#17281)

Tests have been intentionally left out as it is hard to test interaction that relies on local storage.
It also isn't the end of the world if the feature regresses.
This commit is contained in:
Alan Guo Xiang Tan 2022-06-30 15:56:46 +08:00 committed by GitHub
parent 3266350e80
commit 3a6e87ca4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 7 deletions

View File

@ -4,11 +4,27 @@ import { action } from "@ember/object";
import { tracked } from "@glimmer/tracking";
export default class SidebarSection extends GlimmerComponent {
@tracked displaySection = true;
@tracked displaySection;
collapsedSidebarSectionKey = `sidebar-section-${this.args.sectionName}-collapsed`;
constructor() {
super(...arguments);
this.displaySection =
this.keyValueStore.getItem(this.collapsedSidebarSectionKey) === undefined
? true
: false;
}
@action
toggleSectionDisplay() {
this.displaySection = !this.displaySection;
if (this.displaySection) {
this.keyValueStore.remove(this.collapsedSidebarSectionKey);
} else {
this.keyValueStore.setItem(this.collapsedSidebarSectionKey, true);
}
}
get headerCaretIcon() {

View File

@ -155,12 +155,6 @@
border: none;
background: transparent;
padding: 0.25em 0;
opacity: 0;
transition: opacity 0.25s;
&:hover {
opacity: 100;
}
svg {
display: block;