20 lines
480 B
TypeScript
20 lines
480 B
TypeScript
export class ScheduleIconElement extends HTMLElement {
|
|
static iconsPath = "./icons";
|
|
static observedAttributes = ["icon"];
|
|
|
|
constructor() {
|
|
super();
|
|
const icon = this.getAttribute("icon");
|
|
if (icon) {
|
|
this.icon = icon;
|
|
}
|
|
}
|
|
|
|
set icon(value: string) {
|
|
const src = `${ScheduleIconElement.iconsPath}/${value}.svg`;
|
|
fetch(src)
|
|
.then((response) => (response.ok ? response.text() : ""))
|
|
.then((data) => (this.innerHTML = data));
|
|
}
|
|
}
|