Browse Source

add and set my integration of pro-router - as a file as I didn't publish it yet; set the routes

master
Marek Piasecki 1 year ago
parent
commit
5e1e5f64e6
  1. 2
      src/index.js
  2. 33
      src/lib/router_tag.imba
  3. 0
      src/router.imba

2
src/index.js

@ -1 +1,3 @@
import "pro-router/standalone"
import "./router.imba"
import "./main.imba"

33
src/lib/router_tag.imba

@ -0,0 +1,33 @@
tag pro-router
prop view
<self><{ "view-{view || R.view }" }>
tag pro-toggle
prop param
prop disabled
css cursor:pointer cursor.disabled:default
def render
<self.activated=R.params[param] .disabled=disabled @click.if(!disabled)=R.toggle(param)><slot>
tag pro-ref-f < a # f - forget current params in new destination
prop view
prop params = {}
prop go
def render
let link = go || url
<self[d:inline].active=(R.to_path! == link) href=link @click.prevent=(R.go(link); window.scrollTo(0,0))><slot>
get url
R.to_path view, params
tag pro-ref < pro-ref-f
get url
#params = JSON.parse JSON.stringify(params) # duplicate object
#params[k] ||= v for own k, v of R.safe_params
R.to_path view, #params
tag view-not_found
<self><h1> "Page not found :("

0
src/router.imba

Loading…
Cancel
Save