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";
|
2021-04-22 21:49:30 +00:00
|
|
|
import { EVENT_SIDEBAR_TOGGLE, TITLE_DEFAULT } from "../constants";
|
2021-05-29 15:35:56 +00:00
|
|
|
import { tenant } from "../api/Config";
|
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) {
|
2021-05-29 15:35:56 +00:00
|
|
|
tenant().then(tenant => {
|
2021-04-22 21:49:30 +00:00
|
|
|
if (value !== "") {
|
2021-05-29 15:35:56 +00:00
|
|
|
document.title = `${value} - ${tenant.brandingTitle}`;
|
2021-04-22 21:49:30 +00:00
|
|
|
} else {
|
2021-05-29 15:35:56 +00:00
|
|
|
document.title = tenant.brandingTitle || TITLE_DEFAULT;
|
2021-04-22 21:49:30 +00:00
|
|
|
}
|
|
|
|
});
|
2021-04-10 15:06:54 +00:00
|
|
|
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;
|
2021-04-11 16:56:43 +00:00
|
|
|
min-height: 114px;
|
2021-04-10 15:30:23 +00:00
|
|
|
}
|
2021-04-25 16:50:19 +00:00
|
|
|
button.pf-c-button.pf-m-plain.sidebar-trigger {
|
2021-04-10 15:30:23 +00:00
|
|
|
background-color: var(--pf-c-page__main-section--m-light--BackgroundColor);
|
2021-04-11 16:56:43 +00:00
|
|
|
border-radius: 0px;
|
2021-04-10 15:30:23 +00:00
|
|
|
}
|
2021-04-11 11:49:53 +00:00
|
|
|
.pf-c-page__main-section {
|
|
|
|
width: 100%;
|
2021-04-13 15:46:03 +00:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
justify-content: center;
|
2021-04-11 11:49:53 +00:00
|
|
|
}
|
2021-04-11 17:38:24 +00:00
|
|
|
img.pf-icon {
|
|
|
|
max-height: 24px;
|
|
|
|
}
|
2021-04-10 15:30:23 +00:00
|
|
|
`];
|
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>`;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|