From ffc28612fb32ff16220dfda2b54874216b19103d Mon Sep 17 00:00:00 2001 From: Marek Piasecki Date: Tue, 10 Jan 2023 16:52:36 +0100 Subject: [PATCH] example usage of router --- src/main.imba | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/src/main.imba b/src/main.imba index 93c0e34..6fdc471 100644 --- a/src/main.imba +++ b/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 +

'a' + +tag view-b +

'b' + +tag view-c +

'c' + +R.setters.e = do |v| "--{v}" +R.getters.e = do |v| v.slice(2) +tag view-e +

'e' tag app - "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 + + v for v in R.views + 'd' + +