Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import CustomElement from "../../custom-element/CustomElement";
import defineCustomElement from "../../custom-element/helpers/defineCustomElement";
import mergeStyles from "../../custom-element/helpers/mergeStyles";
import { CustomElementPropertyMetadata } from "../../custom-element/interfaces";
import KindMixin from "../../custom-element/mixins/components/kind/KindMixin";
import SizableMixin from "../../custom-element/mixins/components/sizable/SizableMixin";
import { NodePatchingData } from "../../renderer/NodePatcher";
import html from "../../renderer/html";
import styles from "./Alert.css";
//@ts-ignore
export default class Alert extends
SizableMixin(
KindMixin(
CustomElement
)
) {
static get styles(): string {
return mergeStyles(super.styles, styles);
}
static get properties(): Record<string, CustomElementPropertyMetadata> {
return {
/**
* Whether to show the icon
*/
showIcon: {
type: Boolean,
value: true
},
/**
* What action to execute when the alert has been closed
* If it is not defined, then the close tool will not be shown
*/
close: {
type: Function
}
};
}
render(): NodePatchingData {
return html`<gcl-row>
${this._renderIcon()}
<slot></slot>
${this._renderCloseTool()}
</gcl-row>`;
}
private _renderIcon(): NodePatchingData {
const {
showIcon,
kind,
size
} = this;
if (showIcon !== true) {
return null;
}
return html`<gcl-icon name=${this._getIconName()} kind=${kind} size=${size}></gcl-icon>`;
}
private _getIconName(): string {
switch (this.kind) {
case "success": return "check-circle-fill";
case "warning": return "exclamation-circle-fill";
case "error": return "exclamation-circle-fill";
default: return "info-circle-fill";
}
}
private _renderCloseTool(): NodePatchingData {
const {
kind,
size,
} = this;
if (this.close === undefined) {
return null;
}
return html`<gcl-close-tool kind=${kind} size=${size} close=${evt => this.close(evt)} />`;
}
}
defineCustomElement('gcl-alert', Alert); |