[verified] refactor: establish service and frontend boundaries
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
export const VIEW_IDS = Object.freeze(['home', 'detail', 'rawpage', 'api'])
|
||||
export function resolveView(view, hasActiveInstance = false) {
|
||||
return VIEW_IDS.includes(view) ? view : hasActiveInstance ? 'detail' : 'home'
|
||||
}
|
||||
export function createViewRouter({ panels, controls, storage = globalThis.localStorage } = {}) {
|
||||
return view => {
|
||||
for (const control of controls()) control.classList.toggle('active', control.dataset.view === view)
|
||||
for (const panel of panels()) panel.classList.toggle('active', panel.id === `${view}View`)
|
||||
storage?.setItem('multi-simadmin-view', view)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user