import Store from '../modules/store.js';
import text from '../modules/text.js';
class AppBase extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
this.text = text;
this.properties = {
color: '#324BFF',
};
this.store = new Store();
}
connectedCallback() {
this.store.subscribe(this.render.bind(this));
this.render();
}
renderOptions() {
const textList = this.store.getRecords();
return textList.map((item) => ``).join('\n');
}
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.text.title}
${this.text.description}
Delete
Add
`;
}
}
customElements.define('app-base', AppBase);