From 8f60cde71d7a56106673b15d972a60bce1939689 Mon Sep 17 00:00:00 2001 From: rafapaezbas <15270736+rafapaezbas@users.noreply.github.com> Date: Thu, 22 Feb 2024 14:35:07 +0100 Subject: [PATCH] fixed setup ui button click (#68) * fixed setup ui button click * system-status css tweaks * system status html tweaks * system status re-renders after installation * system-status init button inside render logic * simplified system-status button logic * system-status css tweaks --------- Co-authored-by: rafapaezbas --- lib/system-status.js | 45 ++++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/lib/system-status.js b/lib/system-status.js index 1cb9163..6497771 100644 --- a/lib/system-status.js +++ b/lib/system-status.js @@ -71,15 +71,18 @@ customElements.define('system-status', class extends HTMLElement { this.statement = `export PATH="${BIN}":$PATH` this.stmtrx = new RegExp(`^export PATH="${BIN}":\\$PATH$`, 'm') this.shellProfiles = null - this.installed = this.#installed() - this.template = document.createElement('template') - this.template.innerHTML = ` + this.root = this.attachShadow({ mode: 'open' }) + this.#render() + } + + #render () { + this.shadowRoot.innerHTML = `

System Status

${ - this.installed -? '' -: ` + this.#installed() + ? '' + : `

Pear setup is nearly complete.

-

To finish installing Pear Runtime set your system path to ${BIN}${!isWin? ' or click the button bellow.' : '.'}

+

To finish installing Pear Runtime set your system path to

+

${BIN}

+

${!isWin? ' or click the button.' : ''}

${!isWin ? '

' : ''} ` }

` - this.root = this.attachShadow({ mode: 'open' }) - - this.root.appendChild(this.template.content.cloneNode(true)) - - this.button = this.root.querySelector('button') - - if (this.button) { - const listener = () => { - this.button.removeEventListener('click', listener) - this.#install() - .then(() => { - this.replaceWith(new this.constructor()) - console.log('now show version info, and a gif showing pear command line help output run through') - }) - .catch((err) => this.#error(err)) - } - this.button.addEventListener('click', listener) - } + this.shadowRoot.querySelector('button')?.addEventListener('click', () => { + this.#install().then(() => this.#render()).catch((err) => this.#error(err)) + }) } #error (err) {