Sha256: 45561ab3b2a3bb28d52816a6f567ef758cf0c95dd225f4f336b954a094c982ab

Contents?: true

Size: 750 Bytes

Versions: 7

Compression:

Stored size: 750 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 renderWrapper(): string {
    return `<button ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).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

7 entries across 7 versions & 1 rubygems

Version Path
clapton-0.0.24 lib/clapton/javascripts/src/components/button.ts
clapton-0.0.23 lib/clapton/javascripts/src/components/button.ts
clapton-0.0.22 lib/clapton/javascripts/src/components/button.ts
clapton-0.0.21 lib/clapton/javascripts/src/components/button.ts
clapton-0.0.20 lib/clapton/javascripts/src/components/button.ts
clapton-0.0.19 lib/clapton/javascripts/src/components/button.ts
clapton-0.0.18 lib/clapton/javascripts/src/components/button.ts