-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest2.nim
106 lines (86 loc) · 1.99 KB
/
test2.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import std/[macros, dom, sugar]
# Enter word and press enter:
# <input bind:value={name} on:keydown|enter={name=''} /> {name}
# <br />
# <button on:click={click($event)}>Click!</button>
# <!-- <a href on:click|preventDefault={event=$element.textContent}>Click</a> -->
# {event}
import std/jsconsole
when true:
import stardust
when false:
proc createDom(): Element =
var count = 0
var name = cstring""
let call = (ev: Event) => (count += 1)
buildHtml:
text "Enter word and press enter:"
input(onValue=name)
br()
text "{name}"
br()
button(onClick=call):
text "Click me"
text " {count}"
setRenderer createDom
when false:
proc createDom(): Element =
var name = cstring"world"
buildHtml:
h1:
text fmt"Hello {name.toUpperCase()}!"
setRenderer createDom
when false:
var counter1 = 0
var counter2 = 0.5
# proc click() =
# inc counter2
proc createDom(): Element =
buildHtml:
h1:
text "Conquer World!"
`div`:
text "{counter1} => {counter2} => {counter1}"
button:
text fmt"{counter1}"
h2:
`div`:
text "hello"
text fmt"{counter1} => {counter2} => {counter1}"
# button(onclick = click)
# text b"{counter}"
proc main() =
setRenderer createDom
main()
when false:
proc getCstring(): cstring =
result = "we are cool".cstring
proc createDom(): Element =
result = buildHtml:
h1:
text getCstring()
proc main() =
setRenderer createDom
main()
when false:
var counter1 = 0
var counter2 = 0.5
# proc click() =
# inc counter2
proc createDom(): Element =
buildHtml:
h1:
text "Conquer World"
`div`:
text fmt"{counter1}"
button:
text "{counter2}"
h2:
text "{counter1}"
`div`:
text "hello"
# button(onclick = click)
# text b"{counter}"
proc main() =
setRenderer createDom
main()