UNPKG

@kitten-science/kitten-scientists

Version:

Add-on for the wonderful incremental browser game: https://kittensgame.com/web/

47 lines 1.68 kB
import { Container } from "./Container.js"; import styles from "./LabelListItem.module.css"; import { ListItem } from "./ListItem.js"; import stylesListItem from "./ListItem.module.css"; export class LabelListItem extends ListItem { head; elementLabel; /** * Construct a new label list item. * * @param host The userscript instance. * @param label The label on the setting element. * @param options Options for the list item. */ constructor(parent, label, options) { super(parent, options); this.head = new Container(parent); this.head.element.addClass(stylesListItem.head); this.addChild(this.head); this.elementLabel = $("<label/>", { text: `${options?.upgradeIndicator === true ? "⮤ " : ""}${label}`, }) .addClass(styles.label) .addClass(stylesListItem.label); this.head.element.append(this.elementLabel); if (options?.icon) { const iconElement = $("<div/>", { html: `<svg style="width: 15px; height: 15px;" viewBox="0 -960 960 960" fill="currentColor"><path d="${options.icon}"/></svg>`, }).addClass(styles.iconLabel); this.elementLabel.prepend(iconElement); } } toString() { return `[${LabelListItem.name}#${this.componentId}]: '${this.elementLabel.text()}'`; } addChildHead(child) { this.head.addChild(child); return this; } addChildrenHead(children) { for (const child of children ?? []) { this.head.addChild(child); } return this; } } //# sourceMappingURL=LabelListItem.js.map