From 37401a85c8ba3516b56f5b381871841eee1908d3 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 10 Oct 2024 20:04:31 +0200 Subject: [PATCH] Refactor codebase. Functioning item list --- index.html | 20 ++++++++++++++++++-- src/components/app-base.js | 21 ++++++--------------- src/components/custom-button.js | 8 +++----- src/components/item-list.js | 12 ++---------- src/components/main-window.js | 20 ++++++-------------- src/main.js | 29 ----------------------------- src/modules/store.js | 18 +++++++++++------- 7 files changed, 46 insertions(+), 82 deletions(-) diff --git a/index.html b/index.html index 984b921..ba1f989 100644 --- a/index.html +++ b/index.html @@ -8,8 +8,24 @@ - -
+ + + + + + diff --git a/src/components/app-base.js b/src/components/app-base.js index 3acc503..00ac09b 100644 --- a/src/components/app-base.js +++ b/src/components/app-base.js @@ -2,8 +2,6 @@ import Store from '../modules/store.js'; import text from '../modules/text.js'; class AppBase extends HTMLElement { - static observedAttributes = ['title', 'description']; - constructor() { super(); this.attachShadow({ mode: 'open' }); @@ -14,25 +12,18 @@ class AppBase extends HTMLElement { connectedCallback() { this.store.subscribe(this.render.bind(this)); this.render(); - - console.log('Component constructed', this); - } - - disconnectedCallback() { - console.log('Component disconnected', this); - } - - attributeChangedCallback() { - this.render(); } renderText() { const textList = this.store.getRecords(); - const selected = this.store.getSelected(); - return textList.map((item) => ``).join('\n'); + return textList.map((item) => ``).join('\n'); } - render() { + render(action = 'INITIAL') { + if (![Store.actions.ADD_LINE, Store.actions.REMOVE_LINE, Store.actions.UNDO, 'INITIAL'].includes(action)) { + return; // Only render if content changed + } + this.shadowRoot.innerHTML = `