forked from HapticX/happyx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testjs17.nim
74 lines (62 loc) · 1.38 KB
/
testjs17.nim
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
62
63
64
65
66
67
68
69
70
71
72
73
74
import
../src/happyx,
std/macros
var someValue = remember 0
var test = remember ""
proc funcComp1(i: State[int], stmt: TagRef): TagRef =
## You can pass any amount of arguments.
buildHtml:
tDiv:
"i is "
{i}
@click:
i += 1
stmt
proc funcComp2(i: State[int]): TagRef =
buildHtml:
tDiv:
"comp2, so `i` is {i}"
proc funcComp3(): TagRef =
buildHtml:
tDiv:
"comp3 without arguments"
proc funcComp4(id = "", stmt: TagRef): TagRef =
buildHtml:
tDiv:
"comp4 with body"
tInput(id = id, value = test.val):
@input:
test.set($ev.target.value)
stmt
proc Button(stmt: TagRef): TagRef =
buildHtml:
tDiv():
stmt
when enableDefaultComponents:
component NormalComp:
i: State[int]
html:
tDiv:
"And this is common component. i is {self.i}"
appRoutes "app":
"/":
tDiv:
"Here is functional components"
funcComp1(someValue):
"This is functional component slot"
funcComp2(someValue)
funcComp2(i = someValue)
funcComp3()
funcComp3
funcComp4(id = "inp2"):
"Hello"
funcComp1(someValue):
"This is functional component slot"
funcComp4(id = "inp1"):
"world"
when enableDefaultComponents:
NormalComp(someValue)
Button():
"Click me"
tButton():
"Click me"