MyWidget.tsx
50 lines
| 1.3 KiB
| text/x-typescript
|
TypeScriptLexer
|
|
r30 | import { djbase, djclass, bind, prototype, AbstractConstructor } from "../declare"; | ||
|
|
r28 | |||
| import { DjxWidgetBase } from "../tsx/DjxWidgetBase"; | ||||
| import { createElement } from "../tsx"; | ||||
|
|
r30 | interface MyWidgetAttrs { | ||
| title: string; | ||||
| counter: number; | ||||
| } | ||||
| interface MyWidgetEvents { | ||||
| "count-inc": Event; | ||||
| "count-dec": Event; | ||||
| } | ||||
|
|
r28 | |||
| @djclass | ||||
|
|
r30 | export class MyWidget extends djbase(DjxWidgetBase as AbstractConstructor<DjxWidgetBase<MyWidgetAttrs, MyWidgetEvents>>) { | ||
|
|
r28 | |||
|
|
r34 | @bind({ node: "titleNode", type: "innerHTML" }) | ||
|
|
r28 | title = ""; | ||
| @prototype() | ||||
| counter = 0; | ||||
| render() { | ||||
|
|
r34 | const Frame = (props: any) => <div>{props.children}</div>; | ||
|
|
r57 | return <div className="myWidget" onsubmit={e => this._onSubmit(e)} tabIndex={3} style={{ alignContent: "center", border: "1px solid" }} > | ||
|
|
r28 | <h1 data-dojo-attach-point="titleNode"></h1> | ||
|
|
r34 | <Frame> | ||
| <span class="up-button" onclick={e => this._onIncClick(e)}>[+]</span> | ||||
|
|
r41 | <span class="down-button" onclick={() => this._onDecClick()}>[-]</span> | ||
|
|
r34 | </Frame> | ||
|
|
r28 | </div>; | ||
| } | ||||
|
|
r57 | _onSubmit(e: Event) { | ||
| } | ||||
|
|
r34 | _onIncClick(e: MouseEvent) { | ||
| this.emit("count-inc", { bubbles: false }); | ||||
|
|
r30 | } | ||
| _onDecClick() { | ||||
|
|
r34 | this.emit("count-dec", { bubbles: false }); | ||
|
|
r30 | } | ||
|
|
r28 | } | ||
