-
Notifications
You must be signed in to change notification settings - Fork 50
/
Playground.gts
61 lines (48 loc) · 1.57 KB
/
Playground.gts
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
50
51
52
53
54
55
56
57
58
59
60
61
import Component from '@glimmer/component';
import { TOC } from '@ember/component/template-only';
import { hash } from '@ember/helper';
import { ComponentLike, ModifierLike, HelperLike } from '@glint/template';
const lib = {
MaybeComponent: undefined as TOC<{ Args: { arg: string } }> | undefined
};
interface ListSignature<T> {
Args: {
items: Array<T>;
};
Blocks: {
default: [item: T];
};
}
class List<T> extends Component<ListSignature<T>> {
<template>
<ol>
{{#each @items as |item|}}
<li>{{yield item}}</li>
{{/each}}
</ol>
</template>
}
const NUMS = [1, 2, 3];
<template>
<lib.MaybeComponent @arg="hi" />
{{! @glint-expect-error: missing arg }}
<lib.MaybeComponent />
<List @items={{NUMS}} as |item|>
#{{item}}
</List>
{{#each-in (hash a=1 b='hi') as |key value|}}
{{key}}: {{value}}
{{/each-in}}
{{t "NOT IMPORTED!"}}
</template>
declare const CanvasThing: ComponentLike<{ Args: { str: string }; Element: HTMLCanvasElement }>;
declare const makeString: HelperLike<{ Args: { Named: { len: number } }; Return: string }>;
declare const drawCanvasStuff: ModifierLike<{ Args: { Named: { width: number; height: number } }; Element: HTMLCanvasElement }>;
export const CanvasPlayground = <template>
{{#let (component CanvasThing str="hi") as |BoundCanvasThing|}}
<BoundCanvasThing />
{{/let}}
{{#let (helper makeString len=5) (modifier drawCanvasStuff width=10) as |boundMakeString boundDrawCanvasStuff|}}
<CanvasThing @str={{(boundMakeString)}} {{boundDrawCanvasStuff height=5}} />
{{/let}}
</template>