2 changed files with 29 additions and 39 deletions
			
			
		@ -1,39 +0,0 @@ | 
				
			|||
require('pro-router') | 
				
			|||
 | 
				
			|||
tag router | 
				
			|||
	def render | 
				
			|||
		<self view=R.view> <{ view }> | 
				
			|||
 | 
				
			|||
tag switch | 
				
			|||
	prop key | 
				
			|||
	prop disabled | 
				
			|||
 | 
				
			|||
	css cursor:pointer | 
				
			|||
 | 
				
			|||
	def render | 
				
			|||
		<self .activated=R.params[key] .disabled=disabled @click.if(!disabled)=R.toggle(key)> <slot> | 
				
			|||
 | 
				
			|||
tag ref < a | 
				
			|||
	prop view | 
				
			|||
	prop target | 
				
			|||
	prop go | 
				
			|||
 | 
				
			|||
	def render | 
				
			|||
		<self .active=active? href=link @click.prevent.if(!active?)=R.go(href)> <slot> | 
				
			|||
 | 
				
			|||
	def active? | 
				
			|||
		R.to_path == link | 
				
			|||
 | 
				
			|||
	get link do #link ||= go || url | 
				
			|||
 | 
				
			|||
	#tu skonczylem: | 
				
			|||
 | 
				
			|||
	def url | 
				
			|||
		if target | 
				
			|||
			let 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 | 
				
			|||
 | 
				
			|||
tag not_found | 
				
			|||
	def render do <self> "Page not found :/" | 
				
			|||
@ -0,0 +1,29 @@ | 
				
			|||
tag 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 ref-f # f - forget current params in new destination | 
				
			|||
	prop view | 
				
			|||
	prop target = {} | 
				
			|||
	prop go | 
				
			|||
 | 
				
			|||
	def render | 
				
			|||
		let link = go || url | 
				
			|||
		<self[d:inline]><a.active=(R.to_path! == link) href=link @click.prevent=R.go(link)><slot> | 
				
			|||
 | 
				
			|||
	get url | 
				
			|||
		R.to_path view, target | 
				
			|||
 | 
				
			|||
tag ref < ref-f | 
				
			|||
	get url | 
				
			|||
		#target = JSON.parse JSON.stringify(target) # duplicate object | 
				
			|||
		#target[k] ||= v for own k, v of R.safe_params | 
				
			|||
		R.to_path view, #target | 
				
			|||
 | 
				
			|||
tag not_found | 
				
			|||
	<self><h1> "Page not found :(" | 
				
			|||
					Loading…
					
					
				
		Reference in new issue