From 1749249c1c8ca5a8ab9e45ae5475a98981fcbd52 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 11 Oct 2024 00:44:34 +0200 Subject: [PATCH] Add more styling and changed undo behaviour to work correctly when multiple selection is deleted --- src/components/app-base.js | 97 +++++++++++++++++++++++++++++---- src/components/custom-button.js | 4 +- src/components/item-list.js | 2 +- src/components/main-window.js | 26 +++------ src/components/undo-arrow.js | 0 src/main.js | 1 - src/modules/store.js | 17 +++--- 7 files changed, 109 insertions(+), 38 deletions(-) create mode 100644 src/components/undo-arrow.js diff --git a/src/components/app-base.js b/src/components/app-base.js index 00ac09b..42cc92d 100644 --- a/src/components/app-base.js +++ b/src/components/app-base.js @@ -6,6 +6,9 @@ class AppBase extends HTMLElement { super(); this.attachShadow({ mode: 'open' }); this.text = text; + this.properties = { + color: '#324BFF', + }; this.store = new Store(); } @@ -14,27 +17,101 @@ class AppBase extends HTMLElement { this.render(); } - renderText() { + renderOptions() { const textList = this.store.getRecords(); return textList.map((item) => ``).join('\n'); } - render(action = 'INITIAL') { - if (![Store.actions.ADD_LINE, Store.actions.REMOVE_LINE, Store.actions.UNDO, 'INITIAL'].includes(action)) { + render(action = 'INIT') { + if (![Store.actions.ADD_LINE, Store.actions.REMOVE_LINE, Store.actions.UNDO, 'INIT'].includes(action)) { return; // Only render if content changed } this.shadowRoot.innerHTML = ` - - + ${this.renderOptions()} - Delete - Add - Undo + + + + + + + + Delete + Add - + `; } } diff --git a/src/components/custom-button.js b/src/components/custom-button.js index 290e095..7c9c637 100644 --- a/src/components/custom-button.js +++ b/src/components/custom-button.js @@ -1,7 +1,7 @@ import Store from '../modules/store.js'; class CustomButton extends HTMLElement { - static observedAttributes = ['outline', 'color', 'action']; + static observedAttributes = ['outline', 'color', 'width', 'action']; constructor() { super(); @@ -36,7 +36,7 @@ class CustomButton extends HTMLElement { border-style: ${isOutline ? 'solid' : 'hidden'}; border-color: ${this.getAttribute('color')}; opacity: 1; - width: 138px; + width: ${this.getAttribute('width')}; height: 49px; background-color: ${isOutline ? 'white' : this.getAttribute('color')}; color: ${isOutline ? this.getAttribute('color') : 'white'}; diff --git a/src/components/item-list.js b/src/components/item-list.js index 54caa20..f2bc4f6 100644 --- a/src/components/item-list.js +++ b/src/components/item-list.js @@ -21,7 +21,7 @@ class ItemList extends HTMLSelectElement { } updateStyle() { - this.style.width = '800px'; + this.style.width = '100%'; this.style.height = '227px'; this.style.background = '#F7F7F7 0% 0% no-repeat padding-box'; this.style.border = '1px solid #CCCCCC'; diff --git a/src/components/main-window.js b/src/components/main-window.js index f0af685..c579b2b 100644 --- a/src/components/main-window.js +++ b/src/components/main-window.js @@ -15,27 +15,23 @@ class MainWindow extends HTMLElement { } render() { - const title = this.getAttribute('title') || "No title"; - const description = this.getAttribute('description') || "No description"; this.shadowRoot.innerHTML = `