Playground for stylus
This commit is contained in:
		
							
								
								
									
										1
									
								
								components/10_Examples/playground/playground.config.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								components/10_Examples/playground/playground.config.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
{}
 | 
			
		||||
							
								
								
									
										9
									
								
								components/10_Examples/playground/playground.hbs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								components/10_Examples/playground/playground.hbs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
			
		||||
<p class="wred">Red</p>
 | 
			
		||||
<p class="button">button</p>
 | 
			
		||||
<p class="wred button">css combo</p>
 | 
			
		||||
<p class="bluebutton">mixin combo</p>
 | 
			
		||||
 | 
			
		||||
<p class="field">field</p>
 | 
			
		||||
<div class="wurst">
 | 
			
		||||
	<p class="field">wurst field</p>
 | 
			
		||||
</div>
 | 
			
		||||
@@ -3,15 +3,20 @@
 | 
			
		||||
    <head>
 | 
			
		||||
        <meta contentType="text/html; charset=UTF-8"/>
 | 
			
		||||
        <link rel="stylesheet" href="{{ path '/rcss.css' }}">
 | 
			
		||||
		<link rel="stylesheet" href="{{ path '/playground.css' }}">
 | 
			
		||||
        <title>Preview</title>
 | 
			
		||||
 | 
			
		||||
		<style>
 | 
			
		||||
			.red{
 | 
			
		||||
				background-color: firebrick;
 | 
			
		||||
				margin: -2px;
 | 
			
		||||
				border: 1px black solid;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			.green {
 | 
			
		||||
				background-color: forestgreen;
 | 
			
		||||
				margin: -2px;
 | 
			
		||||
				border: 1px black solid;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			.square {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										75
									
								
								components/playground.styl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								components/playground.styl
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,75 @@
 | 
			
		||||
_selector_maps = {}
 | 
			
		||||
_catched = {}
 | 
			
		||||
 | 
			
		||||
throw(id, callback)
 | 
			
		||||
	if id in _selector_maps
 | 
			
		||||
		hook = _selector_maps[id]
 | 
			
		||||
	else    
 | 
			
		||||
		hook = {}
 | 
			
		||||
	
 | 
			
		||||
	hook[selector()] = callback
 | 
			
		||||
	_selector_maps[id] = hook
 | 
			
		||||
 | 
			
		||||
catch(id, params)
 | 
			
		||||
	if selector() in _catched
 | 
			
		||||
		_catches = _catched[selector()]
 | 
			
		||||
	else
 | 
			
		||||
		_catches = {}
 | 
			
		||||
	
 | 
			
		||||
	_catches[id] = params
 | 
			
		||||
	_catched[selector()] = _catches
 | 
			
		||||
 | 
			
		||||
_generate_hooks()
 | 
			
		||||
	for catched_selector, config in _catched
 | 
			
		||||
		for id, parameter in config
 | 
			
		||||
			if id in _selector_maps
 | 
			
		||||
				hook = _selector_maps[id]
 | 
			
		||||
				for thrown_selector, callback in hook
 | 
			
		||||
					{thrown_selector}{catched_selector}
 | 
			
		||||
						callback(parameter)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
red()
 | 
			
		||||
	color red
 | 
			
		||||
	catch('button', green)
 | 
			
		||||
	catch('field', red)
 | 
			
		||||
 | 
			
		||||
field()
 | 
			
		||||
	display inline
 | 
			
		||||
	padding 10px
 | 
			
		||||
	border-bottom 2px solid blue
 | 
			
		||||
	throw('field', @(){
 | 
			
		||||
		border-bottom 2px solid red
 | 
			
		||||
		color blue
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
button()
 | 
			
		||||
	padding 5px
 | 
			
		||||
	background-color orange
 | 
			
		||||
	border 1px solid black
 | 
			
		||||
	display inline
 | 
			
		||||
	throw('button', @(c){color c})
 | 
			
		||||
 | 
			
		||||
.bluebutton
 | 
			
		||||
	red()
 | 
			
		||||
	button()
 | 
			
		||||
 | 
			
		||||
.button
 | 
			
		||||
	button()
 | 
			
		||||
	
 | 
			
		||||
.wred
 | 
			
		||||
	red()
 | 
			
		||||
	
 | 
			
		||||
.field
 | 
			
		||||
	field()
 | 
			
		||||
	
 | 
			
		||||
.wurst
 | 
			
		||||
	.field
 | 
			
		||||
		field()
 | 
			
		||||
		red()
 | 
			
		||||
 | 
			
		||||
.debug
 | 
			
		||||
	--one _selector_maps
 | 
			
		||||
	--two _catched
 | 
			
		||||
	
 | 
			
		||||
_generate_hooks()
 | 
			
		||||
		Reference in New Issue
	
	Block a user