Sha256: 87b1e9d965824bda40a15745a8b724faea317ee104b0c7be679d452772c155ed
Contents?: true
Size: 736 Bytes
Versions: 17
Compression:
Stored size: 736 Bytes
Contents
import { htmlAttributes } from "../html/html-attributes"; export class Button { attributes: Record<string, any>; children: any[]; constructor(attributes: Record<string, any> = {}) { this.attributes = attributes; this.children = []; } add(child: any): Button { this.children.push(child); return this; } get render(): string { return `<button ${htmlAttributes(this.attributes)}>${this.children.map(child => child.render).join("")}</button>`; } add_action(event: string, klass: string, fn: string, options: Record<string, any> = {}): Button { this.attributes["data-action"] = `${this.attributes["data-action"] || ""} ${event}->${klass}#${fn}@${options.debounce || 0}`; return this; } }
Version data entries
17 entries across 17 versions & 1 rubygems