This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/web/src/elements/cards/AggregateCard.ts

71 lines
2.2 KiB
TypeScript
Raw Normal View History

import { CSSResult, LitElement, TemplateResult, css, html } from "lit";
import { customElement, property } from "lit/decorators.js";
import { ifDefined } from "lit/directives/if-defined.js";
import AKGlobal from "@goauthentik/web/authentik.css";
import PFCard from "@patternfly/patternfly/components/Card/card.css";
import PFFlex from "@patternfly/patternfly/layouts/Flex/flex.css";
import PFBase from "@patternfly/patternfly/patternfly-base.css";
2020-12-01 21:17:07 +00:00
2020-12-05 21:08:42 +00:00
@customElement("ak-aggregate-card")
2020-12-01 21:17:07 +00:00
export class AggregateCard extends LitElement {
@property()
icon?: string;
@property()
header?: string;
@property()
headerLink?: string;
@property({ type: Boolean })
isCenter = true;
2020-12-01 21:17:07 +00:00
static get styles(): CSSResult[] {
return [PFBase, PFCard, PFFlex, AKGlobal].concat([
css`
.pf-c-card.pf-c-card-aggregate {
height: 100%;
}
.pf-c-card__header {
flex-wrap: nowrap;
}
.center-value {
font-size: var(--pf-global--icon--FontSize--lg);
text-align: center;
color: var(--pf-global--Color--100);
}
.subtext {
font-size: var(--pf-global--FontSize--sm);
}
`,
]);
2020-12-01 21:17:07 +00:00
}
renderInner(): TemplateResult {
return html`<slot></slot>`;
}
2020-12-16 21:25:44 +00:00
renderHeaderLink(): TemplateResult {
return html`${this.headerLink
? html`<a href="${this.headerLink}">
<i class="fa fa-link"> </i>
</a>`
: ""}`;
2020-12-16 21:25:44 +00:00
}
2020-12-01 21:17:07 +00:00
render(): TemplateResult {
return html`<div class="pf-c-card pf-c-card-aggregate">
<div class="pf-c-card__header pf-l-flex pf-m-justify-content-space-between">
<div class="pf-c-card__title">
<i class="${ifDefined(this.icon)}"></i>&nbsp;${this.header ? this.header : ""}
2020-12-01 21:17:07 +00:00
</div>
2020-12-16 21:25:44 +00:00
${this.renderHeaderLink()}
2020-12-01 21:17:07 +00:00
</div>
<div class="pf-c-card__body ${this.isCenter ? "center-value" : ""}">
${this.renderInner()}
</div>
2020-12-01 21:17:07 +00:00
</div>`;
}
}