Browse Source

prepare for extracting router component to another repo and node package

master
Marek Piasecki 6 years ago
commit
ce202ca54b
  1. 5
      not_found/not_found.imba
  2. 1
      pro-router
  3. 33
      ref/ref.imba
  4. 14
      router_tag.imba
  5. 18
      switch/switch.imba
  6. 1
      switch/switch.scss

5
not_found/not_found.imba

@ -0,0 +1,5 @@
tag not_found
def render
<self>
<h1> 'Page not found'

1
pro-router

@ -0,0 +1 @@
Subproject commit 1e5926668954fe9c56ef16ddfd8b36384032fc38

33
ref/ref.imba

@ -0,0 +1,33 @@
tag ref < a
prop view
prop target
prop go
attr onclick
def setup
@r = R
def render
<self.active=is_active href=link onclick='return false'>
def is_active
var view, params
[ view, params ] = @r.split_path(link)
view == @r:view && L.isEqual params, @r:params
def ontap e
return if is_active
@r.go dom:href
window.scrollTo 0, 0
def link
@go || url
def url
if @target
var attributes = L.reduce L.concat({}, @target), do |map, el|
map[el:type] = el:id
map
@r.to_path @view, L.defaults attributes || {}, @r:safe_params

14
router_tag.imba

@ -0,0 +1,14 @@
global:Router = require('pro-router')
require './ref/ref'
require './switch/switch'
require './not_found/not_found'
tag router
def setup
@r = R
@t = Imba:TAGS
def render
self:__:A = self:__:A || {}
<self> ( self:__:A[@r:view] || self:__:A[@r:view] = @t[@r:view.toUpperCase]() ).end

18
switch/switch.imba

@ -0,0 +1,18 @@
require './switch.scss'
tag switch
prop key
prop disable
def setup
@r = R
def render
<self.is_on=is_on .disabled=@disable>
def is_on
@r:params[@key]
def ontap
@r.toggle key unless @disable

1
switch/switch.scss

@ -0,0 +1 @@
._switch{ cursor: pointer }
Loading…
Cancel
Save