Created
April 10, 2015 16:56
-
-
Save alexeyraspopov/3e4eb6d287e4401b94e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function View(props) { | |
return ( | |
props.allow | |
? HelloWorld({ name: props.name }) | |
: P(null, [Text('Not allowed')]) | |
); | |
} | |
function HelloWorld(props) { | |
return ( | |
Div({ className: 'primary-content' }, [ | |
P(null, [ | |
Text('Hello, ' + props.name) | |
]) | |
]) | |
); | |
} | |
function Div(props, children) { | |
return Element('div', props, children); | |
} | |
function P(props, children) { | |
return Element('p', props, children); | |
} | |
function Element(tag, props, children) { | |
var element = document.createElement(tag); | |
Object.keys(props || {}).forEach(function(key) { | |
element[key] = props[key]; | |
}); | |
children.forEach(element.appendChild, element); | |
return element; | |
// return { node, updater } | |
} | |
function Text(content) { | |
var node = document.createTextNode(content); | |
return node; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment