From ce202ca54ba36c1822a20fb40358aed3cf10d1d7 Mon Sep 17 00:00:00 2001 From: Marek Piasecki Date: Mon, 12 Nov 2018 15:56:51 +0100 Subject: [PATCH] prepare for extracting router component to another repo and node package --- not_found/not_found.imba | 5 +++++ pro-router | 1 + ref/ref.imba | 33 +++++++++++++++++++++++++++++++++ router_tag.imba | 14 ++++++++++++++ switch/switch.imba | 18 ++++++++++++++++++ switch/switch.scss | 1 + 6 files changed, 72 insertions(+) create mode 100644 not_found/not_found.imba create mode 160000 pro-router create mode 100644 ref/ref.imba create mode 100644 router_tag.imba create mode 100644 switch/switch.imba create mode 100644 switch/switch.scss diff --git a/not_found/not_found.imba b/not_found/not_found.imba new file mode 100644 index 0000000..5abbd44 --- /dev/null +++ b/not_found/not_found.imba @@ -0,0 +1,5 @@ +tag not_found + + def render + +

'Page not found' diff --git a/pro-router b/pro-router new file mode 160000 index 0000000..1e59266 --- /dev/null +++ b/pro-router @@ -0,0 +1 @@ +Subproject commit 1e5926668954fe9c56ef16ddfd8b36384032fc38 diff --git a/ref/ref.imba b/ref/ref.imba new file mode 100644 index 0000000..814fa38 --- /dev/null +++ b/ref/ref.imba @@ -0,0 +1,33 @@ +tag ref < a + + prop view + prop target + prop go + + attr onclick + + def setup + @r = R + + def render + + + 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 diff --git a/router_tag.imba b/router_tag.imba new file mode 100644 index 0000000..7ac3285 --- /dev/null +++ b/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:__:A[@r:view] || self:__:A[@r:view] = @t[@r:view.toUpperCase]() ).end diff --git a/switch/switch.imba b/switch/switch.imba new file mode 100644 index 0000000..2c63e58 --- /dev/null +++ b/switch/switch.imba @@ -0,0 +1,18 @@ +require './switch.scss' + +tag switch + + prop key + prop disable + + def setup + @r = R + + def render + + + def is_on + @r:params[@key] + + def ontap + @r.toggle key unless @disable diff --git a/switch/switch.scss b/switch/switch.scss new file mode 100644 index 0000000..3327fd3 --- /dev/null +++ b/switch/switch.scss @@ -0,0 +1 @@ +._switch{ cursor: pointer }