mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
refactor(panels): read panel state from the panel chrome store
PanelChrome, its collapse-preference restore and the phone shell read a panel's disclosure state back from the gev-panel-chrome store (_shownPanel), falling back to the markup's classes before the panel is first presented, instead of reading the classes v-panel-state draws. The share link and the phone shell share one rule for a panel the person keeps closed (prefersCollapsed). The rails, the accordion and the hover disclosure still read the classes, which the directive draws in the same task as their layout.
This commit is contained in:
1 parent
4c92f517db
commit
9ed9098593
12 files changed
+117
-49
No files matched your search
@@ -1,5 +1,6 @@
|
||||
/** Own panel collapsed-state preferences and the one-time layout-reset notice. */
|
||||
import { t } from '../i18n/index.js';
|
||||
import { readPanelState } from './rail/panelState.js';
|
||||
/** Versioned localStorage namespace prefix to invalidate stale panel layouts. */
|
||||
const PANEL_LAYOUT_STORAGE_VERSION = 'v6';
|
||||
/**
|
||||
@@ -14,8 +15,9 @@ const RETIRED_PANEL_KEY_PREFIXES = [
|
||||
`godsEyeView.${PANEL_POSITION_STORAGE_VERSION}.panelFloatHintShown`,
|
||||
];
|
||||
export class PanelPositionControls {
|
||||
constructor({ presentPanel, showToast }) {
|
||||
constructor({ presentPanel, shownPanel = readPanelState, showToast }) {
|
||||
this._presentPanel = presentPanel;
|
||||
this._shownPanel = shownPanel;
|
||||
this._showToast = showToast;
|
||||
}
|
||||
|
||||
@@ -55,7 +57,7 @@ export class PanelPositionControls {
|
||||
_restorePanelCollapsedState(panelId, { allowStored = true } = {}) {
|
||||
const panelEl = document.getElementById(panelId);
|
||||
if (!panelEl) return;
|
||||
let collapsed = panelEl.classList.contains('collapsed');
|
||||
let collapsed = this._shownPanel(panelEl).collapsed;
|
||||
let stored = null;
|
||||
if (allowStored) {
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user