mirror of
https://github.com/aljazceru/pear-docs.git
synced 2025-12-17 22:44:21 +01:00
docs home
This commit is contained in:
@@ -34,7 +34,6 @@ customElements.define('docs-viewer', class extends HTMLElement {
|
|||||||
blockquote::before { content: "ℹ"; float: left; font-size: 1.625rem; margin-left: 1rem; margin-right: 0.625rem; }
|
blockquote::before { content: "ℹ"; float: left; font-size: 1.625rem; margin-left: 1rem; margin-right: 0.625rem; }
|
||||||
img { display: block; max-width: 63em; margin: 0 auto; margin-block-start: 1.625rem; margin-block-end: 1.625rem; box-shadow: rgb(123 115 168 / 15%) 0px 13px 24px 0px; }
|
img { display: block; max-width: 63em; margin: 0 auto; margin-block-start: 1.625rem; margin-block-end: 1.625rem; box-shadow: rgb(123 115 168 / 15%) 0px 13px 24px 0px; }
|
||||||
</style>
|
</style>
|
||||||
<header></header>
|
|
||||||
<div id="panel" class="${lightMode ? 'light' : ''}"><slot></slot></div>
|
<div id="panel" class="${lightMode ? 'light' : ''}"><slot></slot></div>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
@@ -43,7 +42,6 @@ customElements.define('docs-viewer', class extends HTMLElement {
|
|||||||
this.root.appendChild(this.template.content.cloneNode(true))
|
this.root.appendChild(this.template.content.cloneNode(true))
|
||||||
|
|
||||||
this.panel = this.root.querySelector('#panel')
|
this.panel = this.root.querySelector('#panel')
|
||||||
this.header = this.root.querySelector('header')
|
|
||||||
|
|
||||||
this.page = 'readme.md'
|
this.page = 'readme.md'
|
||||||
|
|
||||||
@@ -60,21 +58,27 @@ customElements.define('docs-viewer', class extends HTMLElement {
|
|||||||
const url = new URL(href, location.href)
|
const url = new URL(href, location.href)
|
||||||
if (url.origin !== origin) return window.open(href)
|
if (url.origin !== origin) return window.open(href)
|
||||||
evt.preventDefault()
|
evt.preventDefault()
|
||||||
document.documentElement.scrollTo(0, 0)
|
this.load(evt.target.pathname)
|
||||||
this.page = evt.target.pathname
|
|
||||||
history.pushState(null, null, evt.target.pathname + location.hash)
|
|
||||||
this.#load().catch((err) => this.#error(err))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
window.addEventListener('popstate', (evt) => {
|
window.addEventListener('popstate', (evt) => {
|
||||||
if (location.hash === '#documentation') {
|
if (location.hash.startsWith('#documentation')) {
|
||||||
|
const home = location.hash.endsWith('-home')
|
||||||
|
if (home) {
|
||||||
|
this.page = '/readme.md'
|
||||||
|
history.replaceState(null, null, this.page + location.hash)
|
||||||
|
location.href = '/pulse.html#documentation'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (location.pathname.endsWith('.md') === false) {
|
if (location.pathname.endsWith('.md') === false) {
|
||||||
history.replaceState(null, null, this.page + location.hash)
|
history.replaceState(null, null, this.page + location.hash)
|
||||||
} else {
|
return
|
||||||
evt.preventDefault()
|
}
|
||||||
this.page = location.pathname
|
|
||||||
this.#load().catch((err) => this.#error(err))
|
evt.preventDefault()
|
||||||
}
|
this.page = location.pathname
|
||||||
|
this.#load().catch((err) => this.#error(err))
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -86,6 +90,13 @@ customElements.define('docs-viewer', class extends HTMLElement {
|
|||||||
try { this.panel.querySelector('slot').innerHTML = err.stack } catch (e) { console.error(err, e) }
|
try { this.panel.querySelector('slot').innerHTML = err.stack } catch (e) { console.error(err, e) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
load (page) {
|
||||||
|
document.documentElement.scrollTo(0, 0)
|
||||||
|
this.page = page
|
||||||
|
history.pushState(null, null, page + location.hash)
|
||||||
|
return this.#load().catch((err) => this.#error(err))
|
||||||
|
}
|
||||||
|
|
||||||
async #load () {
|
async #load () {
|
||||||
this.panel.querySelector('slot').innerHTML = marked.parse(await (await fetch(this.page)).text(), {headerIds: false, mangle: false})
|
this.panel.querySelector('slot').innerHTML = marked.parse(await (await fetch(this.page)).text(), {headerIds: false, mangle: false})
|
||||||
}
|
}
|
||||||
|
|||||||
14
pulse.html
14
pulse.html
@@ -32,6 +32,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
a:visited, a:active, a { color: #B0D944; outline: none; text-decoration: none; }
|
a:visited, a:active, a { color: #B0D944; outline: none; text-decoration: none; }
|
||||||
|
a:hover { color: #d944c8; }
|
||||||
|
|
||||||
#logo {
|
#logo {
|
||||||
float: left;
|
float: left;
|
||||||
@@ -118,7 +119,17 @@
|
|||||||
font-size: 2.4rem;
|
font-size: 2.4rem;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
#home {
|
||||||
|
transform: scale(2.2, 2);
|
||||||
|
position: absolute;
|
||||||
|
right: .75rem;
|
||||||
|
bottom: -3.5rem;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
html.light #home {
|
||||||
|
color: #7c9735;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<header>
|
<header>
|
||||||
<div id="headin">
|
<div id="headin">
|
||||||
@@ -145,6 +156,7 @@
|
|||||||
</defs>
|
</defs>
|
||||||
</svg>
|
</svg>
|
||||||
<span id="mode" onclick="document.documentElement.classList[document.documentElement.classList.contains('light') ? 'remove' : 'add']('light');"></span>
|
<span id="mode" onclick="document.documentElement.classList[document.documentElement.classList.contains('light') ? 'remove' : 'add']('light');"></span>
|
||||||
|
<span id="home"><a onclick="document.querySelector('docs-viewer').load('/readme.md')">⌂</a></span>
|
||||||
<span id="back" onclick="history.back()">˿</span>
|
<span id="back" onclick="history.back()">˿</span>
|
||||||
<nav>
|
<nav>
|
||||||
<a href="#status" style="text-indent: -1rem">System Status</a>
|
<a href="#status" style="text-indent: -1rem">System Status</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user