static: add admin shell to improve admin experience

This commit is contained in:
Jens Langhammer
2020-11-20 22:46:05 +01:00
parent 592f2cc558
commit 582dfface9
11 changed files with 249 additions and 188 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,50 @@
import { customElement, html, LitElement, property } from "lit-element";
@customElement("pb-admin-shell")
export class AdminSiteShell extends LitElement {
@property()
set defaultUrl(value: string) {
if (window.location.hash === "" && value !== undefined) {
window.location.hash = `#${value}`;
}
}
createRenderRoot() {
return this;
}
constructor() {
super();
this.loadContent();
window.addEventListener("hashchange", (e) => this.loadContent());
}
loadContent() {
let url = window.location.hash.slice(1, Infinity);
if (url === "") {
return
}
fetch(url).then(r => r.text()).then((t) => {
this.innerHTML = t;
}).then(() => {
this.querySelectorAll("a").forEach(a => {
if (a.href === "") {
return;
}
try {
const url = new URL(a.href);
const qs = url.search || "";
a.href = `#${url.pathname}${qs}`;
} catch (e) {
a.href = `#${a.href}`;
}
});
});
}
render() {
return html`${this.innerHTML}`;
}
}

View File

@ -10,9 +10,6 @@ export class DropdownButton extends LitElement {
btn.addEventListener("click", e => {
menu.hidden = !menu.hidden;
});
btn.addEventListener("blur", e => {
menu.hidden = true;
});
});
}

View File

@ -7,3 +7,4 @@ import './FlowShellCard';
import './Messages';
import './Tabs';
import './ModalButton';
import './AdminSiteShell';