import { css, CSSResult, html, LitElement, property, TemplateResult } from "lit-element"; import { SidebarItem } from "../elements/sidebar/Sidebar"; import PFBase from "@patternfly/patternfly/patternfly-base.css"; import PFPage from "@patternfly/patternfly/components/Page/page.css"; import PFSkipToContent from "@patternfly/patternfly/components/SkipToContent/skip-to-content.css"; import PFButton from "@patternfly/patternfly/components/Button/button.css"; import PFDrawer from "@patternfly/patternfly/components/Drawer/drawer.css"; import "../elements/router/RouterOutlet"; import "../elements/messages/MessageContainer"; import "../elements/notifications/NotificationDrawer"; import "../elements/Banner"; import { until } from "lit-html/directives/until"; import { me } from "../api/Users"; import { t } from "@lingui/macro"; import { EVENT_NOTIFICATION_TOGGLE, EVENT_SIDEBAR_TOGGLE } from "../constants"; export abstract class Interface extends LitElement { @property({type: Boolean}) sidebarOpen = true; @property({type: Boolean}) notificationOpen = false; abstract get sidebar(): SidebarItem[]; static get styles(): CSSResult[] { return [PFBase, PFPage, PFSkipToContent, PFButton, PFDrawer, css` .pf-c-page__main, .pf-c-drawer__content, .pf-c-page__drawer { z-index: auto !important; } `]; } constructor() { super(); this.sidebarOpen = window.innerWidth >= 1280; window.addEventListener("resize", () => { this.sidebarOpen = window.innerWidth >= 1280; }); window.addEventListener(EVENT_SIDEBAR_TOGGLE, () => { this.sidebarOpen = !this.sidebarOpen; }); window.addEventListener(EVENT_NOTIFICATION_TOGGLE, () => { this.notificationOpen = !this.notificationOpen; }); } render(): TemplateResult { return html` ${until(me().then((u) => { if (u.original) { return html` ${t`You're currently impersonating ${u.user.username}.`} ${t`Stop impersonation`} `; } return html``; }))}
`; } }