mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 08:43:25 +08:00
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:
parent
3266350e80
commit
3a6e87ca4f
|
@ -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() {
|
||||
|
|
|
@ -155,12 +155,6 @@
|
|||
border: none;
|
||||
background: transparent;
|
||||
padding: 0.25em 0;
|
||||
opacity: 0;
|
||||
transition: opacity 0.25s;
|
||||
|
||||
&:hover {
|
||||
opacity: 100;
|
||||
}
|
||||
|
||||
svg {
|
||||
display: block;
|
||||
|
|
Loading…
Reference in New Issue
Block a user