web/elements: add Markdown component to improve rendering

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2021-12-16 12:10:46 +01:00
parent 103e723d8c
commit 83089b47d3
2 changed files with 50 additions and 9 deletions

View File

@ -0,0 +1,25 @@
import { CSSResult, LitElement, TemplateResult, html } from "lit";
import { customElement, property } from "lit/decorators.js";
import { unsafeHTML } from "lit/directives/unsafe-html.js";
import AKGlobal from "../authentik.css";
import PFContent from "@patternfly/patternfly/components/Content/content.css";
import PFList from "@patternfly/patternfly/components/List/list.css";
@customElement("ak-markdown")
export class Markdown extends LitElement {
@property()
md?: string;
static get styles(): CSSResult[] {
return [PFList, PFContent, AKGlobal];
}
render(): TemplateResult {
if (!this.md) {
return html``;
}
const finalHTML = this.md.replace("<ul>", `<ul class="pf-c-list">`);
return html`${unsafeHTML(finalHTML)}`;
}
}