diff --git a/lib/docs-viewer.js b/lib/docs-viewer.js index a50bda8..287b953 100644 --- a/lib/docs-viewer.js +++ b/lib/docs-viewer.js @@ -43,7 +43,11 @@ customElements.define('docs-viewer', class extends HTMLElement { this.panel = this.root.querySelector('#panel') - this.page = 'readme.md' + this.home = document.querySelector('#home') + + this.page = '/readme.md' + + this.home.style.display = 'none' const observer = new MutationObserver(() => { if (document.documentElement.classList.contains('light')) this.panel.classList.add('light') @@ -61,6 +65,11 @@ customElements.define('docs-viewer', class extends HTMLElement { this.load(evt.target.pathname) }) + window.addEventListener('hashchange', () => { + if (location.hash === '#documentation' && this.page === '/readme.md') this.home.style.display = 'none' + else this.home.style.display = '' + }) + window.addEventListener('popstate', (evt) => { if (location.hash.startsWith('#documentation')) { const home = location.hash.endsWith('-home') @@ -99,5 +108,7 @@ customElements.define('docs-viewer', class extends HTMLElement { async #load () { this.panel.querySelector('slot').innerHTML = marked.parse(await (await fetch(this.page)).text(), {headerIds: false, mangle: false}) + if (location.hash === '#documentation' && this.page === '/readme.md') this.home.style.display = 'none' + else this.home.style.display = '' } }) diff --git a/lib/system-status.js b/lib/system-status.js new file mode 100644 index 0000000..7449aba --- /dev/null +++ b/lib/system-status.js @@ -0,0 +1,72 @@ +import fs from 'fs' +import path from 'path' +import { config } from 'pear' + +const pearBin = path.join(config.pearDir, 'bin') + +const paths = process.env.PATH.split(path.delimiter) + +customElements.define('system-status', class extends HTMLElement { + constructor () { + super() + this.vianode = false + this.installed = paths.some((p) => { + if (p.includes('node') && p.includes('bin')) this.vianode = fs.existsSync(path.join(p, 'pear')) + return p === pearBin + }) + this.template = document.createElement('template') + this.template.innerHTML = ` +
++Pear is installed.
+
✔ Pear is in the system PATH and ready to go.
+ ` : ` +++Pear setup is nearly complete.
+
+
Click the button to add ${pearBin} to the system PATH
--Pear is installed.
-
Pear is ready to go.
+