mirror of
https://github.com/goauthentik/authentik.git
synced 2026-08-30 18:51:39 -07:00
* core: Bump packages. * Bump Live Reload dependencies. * Bump tsconfig. * Bum ESLint config deps. Fix formatting. * Bump Prettier deps. Fix ESlint config. * Bump live reload deps. Fix linter. * Bump website deps. * web: Update dependencies. Fix Playwright issues. * Fix deprecations. * Fix linter warnings. * Fix override, run audit. * Fix import path. * Tidy types. * Format. * Update ignore patterns. * Fix import path. * Update deps. Clean up workspace linting. * Update deps, options. * Hide icons in navbar. * Format. * Remove deprecated option. * Use relative packages. * Add scripts. Tidy. * Bump engines. * Clarify order. * Clarify order. Install base deps. * Format. * Fix stale user during tests. * Fix runtime errors. * Fix redirect during tests, UI change. * web: Fix danger button hover background color. * web: Adjust colors, padding. * web: Fix sidebar colors, padding. * Fix alignment. * Fix background contrast.
92 lines
2.6 KiB
TypeScript
92 lines
2.6 KiB
TypeScript
import { AKElement } from "#elements/Base";
|
|
import type { SlottedTemplateResult, Spread } from "#elements/types";
|
|
|
|
import { spread } from "@open-wc/lit-helpers";
|
|
|
|
import { html, nothing } from "lit";
|
|
import { customElement, property } from "lit/decorators.js";
|
|
import { classMap } from "lit/directives/class-map.js";
|
|
|
|
import PFLabel from "@patternfly/patternfly/components/Label/label.css";
|
|
|
|
export enum PFColor {
|
|
Green = "pf-m-green",
|
|
Orange = "pf-m-orange",
|
|
Red = "pf-m-red",
|
|
Blue = "pf-m-blue",
|
|
Grey = "",
|
|
}
|
|
|
|
export const levelNames = ["warning", "info", "success", "danger"];
|
|
export type Level = (typeof levelNames)[number];
|
|
|
|
type Chrome = [Level, PFColor, string, string];
|
|
const chromeList: Chrome[] = [
|
|
["danger", PFColor.Red, "pf-m-red", "fa-times"],
|
|
["warning", PFColor.Orange, "pf-m-orange", "fa-exclamation-triangle"],
|
|
["success", PFColor.Green, "pf-m-green", "fa-check"],
|
|
["running", PFColor.Blue, "pf-m-blue", "fa-clock"],
|
|
["info", PFColor.Grey, "pf-m-grey", "fa-info-circle"],
|
|
];
|
|
|
|
export interface ILabel {
|
|
icon?: string;
|
|
compact?: boolean;
|
|
color?: string;
|
|
}
|
|
|
|
@customElement("ak-label")
|
|
export class Label extends AKElement implements ILabel {
|
|
@property()
|
|
color: PFColor = PFColor.Grey;
|
|
|
|
@property()
|
|
icon?: string;
|
|
|
|
@property({ type: Boolean })
|
|
compact = false;
|
|
|
|
static styles = [PFLabel];
|
|
|
|
get classesAndIcon() {
|
|
const chrome = chromeList.find(
|
|
([level, color]) => this.color === level || this.color === color,
|
|
);
|
|
|
|
const [illo, icon] = chrome ? chrome.slice(2) : ["pf-m-grey", "fa-info-circle"];
|
|
|
|
return {
|
|
classes: {
|
|
"pf-c-label": true,
|
|
"pf-m-compact": this.compact,
|
|
...(illo ? { [illo]: true } : {}),
|
|
},
|
|
icon: this.icon ? this.icon : icon,
|
|
};
|
|
}
|
|
|
|
render() {
|
|
const { classes, icon } = this.classesAndIcon;
|
|
|
|
return html`<span class=${classMap(classes)}>
|
|
<span class="pf-c-label__content">
|
|
<span class="pf-c-label__icon">
|
|
<i class="fas fa-fw ${icon}" aria-hidden="true"></i>
|
|
</span>
|
|
<slot></slot>
|
|
</span>
|
|
</span>`;
|
|
}
|
|
}
|
|
|
|
export function akLabel(properties: ILabel, content: SlottedTemplateResult = nothing) {
|
|
const message = typeof content === "string" ? html`<span>${content}</span>` : content;
|
|
return html`<ak-label ${spread(properties as Spread)}>${message}</ak-label>`;
|
|
}
|
|
|
|
declare global {
|
|
interface HTMLElementTagNameMap {
|
|
"ak-label": Label;
|
|
}
|
|
}
|