simplifications
This commit is contained in:
parent
f5e9db55c3
commit
393c336f90
1 changed files with 9 additions and 22 deletions
|
|
@ -26,7 +26,6 @@ type
|
||||||
anim: AnimState
|
anim: AnimState
|
||||||
tree: TreeState
|
tree: TreeState
|
||||||
|
|
||||||
var container = document.getElementById("#App")
|
|
||||||
var appState: AppState
|
var appState: AppState
|
||||||
|
|
||||||
proc createTableCell(id: cstring): VNode =
|
proc createTableCell(id: cstring): VNode =
|
||||||
|
|
@ -44,18 +43,13 @@ proc createTableRow(item: TableItemState): VNode =
|
||||||
children.add createTableCell("#" & &item.id)
|
children.add 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 = &item.id
|
|
||||||
|
|
||||||
proc createRow(): VNode =
|
var className = cstring"TableRow"
|
||||||
kout cstring"createRow"
|
if item.active:
|
||||||
var className = cstring"TableRow"
|
className = cstring"TableRow active"
|
||||||
if item.active:
|
result = buildHtml(tr(class=className, `data-id` = &item.id)):
|
||||||
className = cstring"TableRow active"
|
for child in children:
|
||||||
result = buildHtml(tr(class=className, `data-id`=dataId)):
|
child
|
||||||
for child in children:
|
|
||||||
child
|
|
||||||
|
|
||||||
result = createRow()
|
|
||||||
|
|
||||||
|
|
||||||
proc tableCreateVNode(data: TableState): VNode =
|
proc tableCreateVNode(data: TableState): VNode =
|
||||||
|
|
@ -70,19 +64,14 @@ proc createAnimBox(item: AnimBoxState): VNode =
|
||||||
var time = item.time
|
var time = item.time
|
||||||
var dataId: cstring = &item.id
|
var dataId: cstring = &item.id
|
||||||
var color: float = float(time mod 10) / 10
|
var color: float = float(time mod 10) / 10
|
||||||
var divStyles: cstring = "borderRadius: " & &(time mod 10) & "px; background: rgba(0,0,0," & cstring($color) & ")"
|
var divStyles: cstring = "border-radius: " & &(time mod 10) & "px; background: rgba(0,0,0," & cstring($color) & ")"
|
||||||
result = flatHtml(tdiv(class="AnimBox", `data-id`=dataId, style=divStyles))
|
result = flatHtml(tdiv(class="AnimBox", `data-id`=dataId, style=divStyles))
|
||||||
|
|
||||||
proc animCreateVNode(data: AnimState): VNode =
|
proc animCreateVNode(data: AnimState): VNode =
|
||||||
kout cstring"animCreateVNode"
|
kout cstring"animCreateVNode"
|
||||||
var items = data.items
|
|
||||||
var children: seq[VNode] = @[]
|
|
||||||
for i in 0..<len(children):
|
|
||||||
var item = items[i]
|
|
||||||
children.add createAnimBox(item)
|
|
||||||
result = buildHtml(tdiv(class="Anim")):
|
result = buildHtml(tdiv(class="Anim")):
|
||||||
for child in children:
|
for child in data.items:
|
||||||
child
|
createAnimBox(child)
|
||||||
|
|
||||||
proc createTreeLeaf(data: TreeNodeState): VNode =
|
proc createTreeLeaf(data: TreeNodeState): VNode =
|
||||||
kout cstring"createTreeLeaf"
|
kout cstring"createTreeLeaf"
|
||||||
|
|
@ -106,7 +95,6 @@ proc treeCreateVNode(data: TreeState): VNode =
|
||||||
|
|
||||||
|
|
||||||
proc update(): VNode =
|
proc update(): VNode =
|
||||||
kout cstring"update"
|
|
||||||
if appState == nil:
|
if appState == nil:
|
||||||
kout cstring"stupid fuck"
|
kout cstring"stupid fuck"
|
||||||
return newVNode(VNodeKind.tdiv)
|
return newVNode(VNodeKind.tdiv)
|
||||||
|
|
@ -118,7 +106,6 @@ 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)
|
||||||
kout cstring"update", children
|
|
||||||
result = buildHtml():
|
result = buildHtml():
|
||||||
tdiv(class="Main"):
|
tdiv(class="Main"):
|
||||||
children
|
children
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue