2021-04-10 15:30:23 +00:00
|
|
|
import { css, CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element";
|
2021-04-10 15:06:54 +00:00
|
|
|
import PFPage from "@patternfly/patternfly/components/Page/page.css";
|
|
|
|
import PFContent from "@patternfly/patternfly/components/Content/content.css";
|
|
|
|
import AKGlobal from "../authentik.css";
|
|
|
|
import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
2021-04-10 15:30:23 +00:00
|
|
|
import PFButton from "@patternfly/patternfly/components/Button/button.css";
|
|
|
|
import { EVENT_SIDEBAR_TOGGLE, TITLE_SUFFIX } from "../constants";
|
2021-04-10 15:06:54 +00:00
|
|
|
|
|
|
|
@customElement("ak-page-header")
|
|
|
|
export class PageHeader extends LitElement {
|
|
|
|
|
|
|
|
@property()
|
|
|
|
icon?: string;
|
|
|
|
|
|
|
|
@property({type: Boolean})
|
|
|
|
iconImage = false
|
|
|
|
|
|
|
|
@property()
|
|
|
|
set header(value: string) {
|
|
|
|
if (value !== "") {
|
|
|
|
document.title = `${value} - ${TITLE_SUFFIX}`;
|
|
|
|
} else {
|
|
|
|
document.title = TITLE_SUFFIX;
|
|
|
|
}
|
|
|
|
this._header = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
get header(): string {
|
|
|
|
return this._header;
|
|
|
|
}
|
|
|
|
|
|
|
|
@property()
|
|
|
|
description?: string;
|
|
|
|
|
|
|
|
_header = "";
|
|
|
|
|
|
|
|
static get styles(): CSSResult[] {
|
2021-04-10 15:30:23 +00:00
|
|
|
return [PFBase, PFButton, PFPage, PFContent, AKGlobal, css`
|
|
|
|
:host {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
}
|
|
|
|
button.sidebar-trigger {
|
|
|
|
background-color: var(--pf-c-page__main-section--m-light--BackgroundColor);
|
|
|
|
}
|
|
|
|
`];
|
2021-04-10 15:06:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
renderIcon(): TemplateResult {
|
|
|
|
if (this.icon) {
|
|
|
|
if (this.iconImage) {
|
|
|
|
return html`<img class="pf-icon" src="${this.icon}" /> `;
|
|
|
|
}
|
|
|
|
return html`<i class=${this.icon}></i> `;
|
|
|
|
}
|
|
|
|
return html``;
|
|
|
|
}
|
|
|
|
|
|
|
|
render(): TemplateResult {
|
2021-04-10 15:30:23 +00:00
|
|
|
return html`<button
|
|
|
|
class="sidebar-trigger pf-c-button pf-m-plain"
|
|
|
|
@click=${() => {
|
|
|
|
this.dispatchEvent(
|
|
|
|
new CustomEvent(EVENT_SIDEBAR_TOGGLE, {
|
|
|
|
bubbles: true,
|
|
|
|
composed: true,
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}}>
|
|
|
|
<i class="fas fa-bars"></i>
|
|
|
|
</button>
|
|
|
|
<section class="pf-c-page__main-section pf-m-light">
|
2021-04-10 15:06:54 +00:00
|
|
|
<div class="pf-c-content">
|
|
|
|
<h1>
|
|
|
|
${this.renderIcon()}
|
|
|
|
${this.header}
|
|
|
|
</h1>
|
|
|
|
${this.description ?
|
2021-04-10 15:30:23 +00:00
|
|
|
html`<p>${this.description}</p>` : html``}
|
2021-04-10 15:06:54 +00:00
|
|
|
</div>
|
|
|
|
</section>`;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|