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";
|
2021-01-14 21:02:21 +00:00
|
|
|
import "../elements/notifications/NotificationDrawer";
|
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 22:12:13 +00:00
|
|
|
sidebarOpen = true;
|
2020-12-02 12:56:26 +00:00
|
|
|
|
2021-01-14 20:58:10 +00:00
|
|
|
@property({type: Boolean})
|
|
|
|
notificationOpen = false;
|
|
|
|
|
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;
|
|
|
|
});
|
2021-01-14 20:58:10 +00:00
|
|
|
window.addEventListener("ak-notification-toggle", () => {
|
|
|
|
this.notificationOpen = !this.notificationOpen;
|
|
|
|
});
|
2020-12-19 15:54:25 +00:00
|
|
|
}
|
|
|
|
|
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>
|
2021-01-14 20:58:10 +00:00
|
|
|
<div class="pf-c-page__drawer">
|
|
|
|
<div class="pf-c-drawer ${this.notificationOpen ? "pf-m-expanded" : "pf-m-collapsed"}">
|
|
|
|
<div class="pf-c-drawer__main">
|
|
|
|
<div class="pf-c-drawer__content">
|
|
|
|
<div class="pf-c-drawer__body">
|
|
|
|
<main class="pf-c-page__main">
|
|
|
|
<ak-router-outlet role="main" class="pf-c-page__main" tabindex="-1" id="main-content" defaultUrl="/library">
|
|
|
|
</ak-router-outlet>
|
|
|
|
</main>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<ak-notification-drawer class="pf-c-drawer__panel pf-m-width-33">
|
|
|
|
</ak-notification-drawer>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-12-02 12:56:26 +00:00
|
|
|
</div>`;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|