ayoayco / web-component-base

Web Components in Easy Mode 🧱
https://WebComponent.io
MIT License
71 stars 2 forks source link

feat: props blueprint #8

Closed ayoayco closed 11 months ago

ayoayco commented 11 months ago

🎉 New way to define and initialize props on WebComponent.io as of v2.0.0-beta.6

This should ease the friction in defining properties with kebab-case strings and switching to camelCase when working with the values. Also, needing to initialize the values inside the onInit hook is unnecessary now.

export class Counter extends WebComponent {
  static props = {
    count: 123,
  };
  onInit() {
    this.onclick = () => ++this.props.count;
  }
  get template() {
    return `<button id="btn">${this.props.count}</button>`;
  }
}
vercel[bot] commented 11 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
web-component-base ✅ Ready (Inspect) Visit Preview Dec 8, 2023 5:00pm