Browse Source

example usage of router

master
Marek Piasecki 2 years ago
parent
commit
ffc28612fb
  1. 46
      src/main.imba

46
src/main.imba

@ -1,16 +1,42 @@
export let state = {
count: 0
}
import "./router_tag.imba"
import { compact, fromPairs, chunk, includes, reject, toPairs, flatten } from 'lodash'
export def increment
state.count++
let helpers =
compact: compact
fromPairs: fromPairs
chunk: chunk
includes: includes
reject: reject
toPairs: toPairs
flatten: flatten
R.init(helpers: helpers, views: ['a', 'b', 'c'], root: 'a', render: imba.commit)
tag view-a
<self><h1> 'a'
tag view-b
<self><h1> 'b'
tag view-c
<self><h1> 'c'
R.setters.e = do |v| "--{v}"
R.getters.e = do |v| v.slice(2)
tag view-e
<self><h1> 'e'
tag app
<self@click=increment> "count is {state.count}"
css d:inline-block us:none cursor:pointer fs:6 p:2.5 5 rd:2.5
tween:box-shadow 250ms, background-color 250ms
ff:Arial c:black/87 bg:indigo4 bxs:xs
@hover bg:indigo3 bxs:lg
<self[d:bbox]>
<pro-ref view=v> v for v in R.views
<pro-ref view="d"> 'd'
<pro-toggle param="O">
<label> "O"
<input type='checkbox' checked=R.param('O')>
<pro-ref view="b" params={ project: 2}> "b/project/2"
<pro-ref-f view="c" params={ book: 3}> "c/book/3"
<pro-router>
<input$v type='text' value=R.param('e') @keyup=R.write('e', $v.value)>
if import.meta.env.MODE is 'development'
imba.mount <app>

Loading…
Cancel
Save