more progress

This commit is contained in:
Andreas Rumpf 2017-04-27 14:05:11 +02:00
commit 41df9b769f
2 changed files with 16 additions and 19 deletions

View file

@ -9,5 +9,8 @@
<div id="App"></div> <div id="App"></div>
<script src="https://localvoid.github.io/uibench-base/0.1.0/uibench.js"></script> <script src="https://localvoid.github.io/uibench-base/0.1.0/uibench.js"></script>
<script src="nimcache/nim_uibench.js" type="text/javascript"></script> <script src="nimcache/nim_uibench.js" type="text/javascript"></script>
<div id="ROOT"></div>
</body> </body>
</html> </html>

View file

@ -41,12 +41,11 @@ proc createTableCell(id: cstring): VNode =
result = buildHtml(td(className="TableCell", onclick=tableCellClick)): result = buildHtml(td(className="TableCell", onclick=tableCellClick)):
text id text id
proc createTableRow(item: TableItemState): VNode = proc createTableRow(item: TableItemState): VNode =
var children = createTableCell("#" & &item.id) var children = createTableCell("#" & &item.id)
for i in 0..<len(item.props): for i in 0..<len(item.props):
children.add(createTableCell(item.props[i])) children.add(createTableCell(item.props[i]))
var dataId = cstring($item.id) var dataId = &item.id
proc createRow(): VNode = proc createRow(): VNode =
var className = cstring"TableRow" var className = cstring"TableRow"
@ -58,17 +57,10 @@ proc createTableRow(item: TableItemState): VNode =
proc tableCreateVNode(data: TableState): VNode = proc tableCreateVNode(data: TableState): VNode =
var childrens: seq[VNode] = @[]
for i in 0..<len(data.items):
childrens.add createTableRow(data.items[i])
proc createTable(): VNode =
result = buildHtml(table(class="Table")): result = buildHtml(table(class="Table")):
tbody: tbody:
for child in childrens: for child in data.items:
child createTableRow(child)
result = createTable()
proc createAnimBox(item: AnimBoxState): VNode = proc createAnimBox(item: AnimBoxState): VNode =
var time = item.time var time = item.time
@ -115,17 +107,19 @@ proc update(): VNode =
children = animCreateVNode(appState.anim) children = animCreateVNode(appState.anim)
elif location == cstring"tree": elif location == cstring"tree":
children = treeCreateVNode(appState.tree) children = treeCreateVNode(appState.tree)
proc createMain(): VNode = kout cstring"update", children
result = buildHtml(tdiv(class="Main")): children result = buildHtml():
result = createMain() tdiv(class="Main"):
children
proc a(state: AppState) = proc a(state: AppState) =
appState = state appState = state
redraw()
proc b(samples: RootRef) = proc b(samples: RootRef) =
document.body.innerHTML = cstring"<pre>" & toJson(samples) & cstring"</pre>" #document.body.innerHTML = cstring"<pre>" & toJson(samples) & cstring"</pre>"
redraw() #redraw()
discard
kout cstring"updating" kout cstring"updating"
setRenderer update setRenderer update