diff --git a/web/src/elements/chips/Chip.ts b/web/src/elements/chips/Chip.ts new file mode 100644 index 000000000..58f544798 --- /dev/null +++ b/web/src/elements/chips/Chip.ts @@ -0,0 +1,39 @@ +import { CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element"; + +import PFBase from "@patternfly/patternfly/patternfly-base.css"; +import PFButton from "@patternfly/patternfly/components/Button/button.css"; +import PFChip from "@patternfly/patternfly/components/Chip/chip.css"; +import AKGlobal from "../../authentik.css"; + +@customElement("ak-chip") +export class Chip extends LitElement { + + @property() + value?: number | string; + + @property({type: Boolean}) + removable = false; + + static get styles(): CSSResult[] { + return [PFBase, PFButton, PFChip, AKGlobal]; + } + + render(): TemplateResult { + return html`
  • +
    + + + + ${this.removable ? html`` : html``} +
    +
  • `; + } + +} diff --git a/web/src/elements/chips/ChipGroup.ts b/web/src/elements/chips/ChipGroup.ts new file mode 100644 index 000000000..cf16d3715 --- /dev/null +++ b/web/src/elements/chips/ChipGroup.ts @@ -0,0 +1,37 @@ +import { CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element"; + +import PFBase from "@patternfly/patternfly/patternfly-base.css"; +import PFChip from "@patternfly/patternfly/components/Chip/chip.css"; +import PFChipGroup from "@patternfly/patternfly/components/ChipGroup/chip-group.css"; +import PFButton from "@patternfly/patternfly/components/Button/button.css"; +import AKGlobal from "../../authentik.css"; +import { Chip } from "./Chip"; + +@customElement("ak-chip-group") +export class ChipGroup extends LitElement { + + static get styles(): CSSResult[] { + return [PFBase, PFChip, PFChipGroup, PFButton, AKGlobal]; + } + + set value(v: (string | number | undefined)[]) {} + + get value(): (string | number | undefined)[] { + const values: (string | number | undefined)[] = []; + this.querySelectorAll("ak-chip").forEach(chip => { + values.push(chip.value); + }); + return values; + } + + render(): TemplateResult { + return html`
    +
    +
      + +
    +
    +
    `; + } + +}