-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathExampleComponent.ts
More file actions
49 lines (39 loc) · 1.44 KB
/
ExampleComponent.ts
File metadata and controls
49 lines (39 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import {asFactory, Composite, ObservableData, ProgressBar, Properties, Setter, Stack, TextView} from 'tabris';
import {bind, component, prop, property} from 'tabris-decorators';
export class OtherModel extends ObservableData {
someString: string = 'Hello World';
}
export class Model {
@property({observe: true}) otherModel: OtherModel = new OtherModel();
@prop someNumber: number = 10;
}
namespace internal {
@component
export class ExampleComponent extends Composite {
@bind('>> #text1.text')
myText: string;
@bind('>> ProgressBar.selection', (obj: Model) => obj?.someNumber)
@bind('>> #text2.text', (obj: Model) => obj?.otherModel?.someString)
myObject: Model;
constructor(properties: Properties<ExampleComponent>) {
super();
this.set(properties);
this.append(
Stack({
spacing: 12,
padding: 12,
apply: Setter(TextView, {font: {size: 21}}),
children: [
TextView({text: 'Binding to a component property'}),
TextView({id: 'text1', text: 'Placeholder', background: 'yellow'}),
TextView({text: 'Binding to an object property:'}),
ProgressBar({width: 200}),
TextView({text: 'Binding to a nested object property:'}),
TextView({id: 'text2', text: 'Placeholder', background: 'yellow'})
]
})
);
}
}
}
export const ExampleComponent = asFactory(internal.ExampleComponent);