Cleaner CSS page management

This commit is contained in:
Magnus Åhall 2026-06-12 07:12:38 +02:00
parent cc2415a06d
commit 5dac84efdc
2 changed files with 39 additions and 30 deletions

View file

@ -4,6 +4,8 @@ import { N2Sidebar } from 'sidebar'
import { Node } from 'node'
export class App {
static PAGES = ['node', 'history', 'storage']
constructor() {// {{{
this.currentNode = null
this.sidebar = new N2Sidebar()
@ -16,12 +18,15 @@ export class App {
document.getElementById('tree-nodes')?.focus()
})
const mainPage = document.getElementById('main-page')
// Start node shows a system-wide page instead of node editing
// since the start node is kind of magic and doesn't fit into
// the syncing system.
const determineNodePage = uuid => {
const el = document.getElementById('notes2')
if (uuid == ROOT_NODE)
mainPage.classList.add('root-node-override')
el.classList.add('root-node-override')
else
mainPage.classList.remove('root-node-override')
el.classList.remove('root-node-override')
}
_mbus.subscribe('TREE_RENDERED', async () => {
@ -47,13 +52,7 @@ export class App {
})
_mbus.subscribe('SHOW_PAGE', ({ detail: { data: { page } } }) => {
let classList = document.querySelector('#main-page').classList
classList.forEach(e =>
classList.remove(e)
)
classList.add(page)
classList = document.querySelector('#notes2').classList
const classList = document.getElementById('notes2').classList
classList.forEach(e => {
if (e.startsWith('page-'))
classList.remove(e)