2020-12-02 12:56:26 +00:00
|
|
|
import { gettext } from "django";
|
2020-12-19 15:54:25 +00:00
|
|
|
import { html, LitElement, property, TemplateResult } from "lit-element";
|
2020-12-02 12:56:26 +00:00
|
|
|
import { SidebarItem } from "../elements/sidebar/Sidebar";
|
|
|
|
|
2020-12-12 18:39:09 +00:00
|
|
|
import "../elements/router/RouterOutlet";
|
2020-12-12 19:46:02 +00:00
|
|
|
import "../elements/messages/MessageContainer";
|
2020-12-19 15:54:25 +00:00
|
|
|
import "../elements/sidebar/SidebarHamburger";
|
2020-12-02 14:44:40 +00:00
|
|
|
|
2020-12-02 12:56:26 +00:00
|
|
|
export abstract class Interface extends LitElement {
|
2020-12-19 15:54:25 +00:00
|
|
|
@property({type: Boolean})
|
2020-12-30 21:45:00 +00:00
|
|
|
sidebarOpen: boolean = true;
|
2020-12-02 12:56:26 +00:00
|
|
|
|
|
|
|
abstract get sidebar(): SidebarItem[];
|
|
|
|
|
2020-12-02 14:44:40 +00:00
|
|
|
createRenderRoot(): ShadowRoot | Element {
|
|
|
|
return this;
|
2020-12-02 12:56:26 +00:00
|
|
|
}
|
|
|
|
|
2020-12-19 15:54:25 +00:00
|
|
|
constructor() {
|
|
|
|
super();
|
2020-12-20 18:26:30 +00:00
|
|
|
this.sidebarOpen = window.outerWidth >= 1280;
|
|
|
|
window.addEventListener("resize", () => {
|
|
|
|
this.sidebarOpen = window.outerWidth >= 1280;
|
|
|
|
});
|
2020-12-19 15:54:25 +00:00
|
|
|
window.addEventListener("ak-sidebar-toggle", () => {
|
|
|
|
this.sidebarOpen = !this.sidebarOpen;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-12-02 12:56:26 +00:00
|
|
|
render(): TemplateResult {
|
2020-12-12 19:46:02 +00:00
|
|
|
return html`<ak-message-container></ak-message-container>
|
2020-12-02 12:56:26 +00:00
|
|
|
<div class="pf-c-page">
|
|
|
|
<a class="pf-c-skip-to-content pf-c-button pf-m-primary" href="#main-content">${gettext("Skip to content")}</a>
|
2020-12-19 15:54:25 +00:00
|
|
|
<ak-sidebar-hamburger>
|
|
|
|
</ak-sidebar-hamburger>
|
|
|
|
<ak-sidebar class="pf-c-page__sidebar ${this.sidebarOpen ? "pf-m-expanded" : "pf-m-collapsed"}" .items=${this.sidebar}>
|
2020-12-05 21:08:42 +00:00
|
|
|
</ak-sidebar>
|
2020-12-02 12:56:26 +00:00
|
|
|
<main class="pf-c-page__main">
|
2020-12-28 12:07:35 +00:00
|
|
|
<ak-router-outlet role="main" class="pf-c-page__main" tabindex="-1" id="main-content" defaultUrl="/library">
|
2020-12-05 21:08:42 +00:00
|
|
|
</ak-router-outlet>
|
2020-12-02 12:56:26 +00:00
|
|
|
</main>
|
|
|
|
</div>`;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|