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
export function createComponent(render) { | |
var def = typeof render === 'function' ? {render: render} : render; | |
render = def.render; | |
def.render = function () { | |
const {data, children} = this.props; | |
return render.call(this, data, children); | |
}; | |
if (!def.getInitialState) { |
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
/*global React*/ | |
import {createApp} from '../../src/reapp'; | |
import assign from 'lodash/object/assign'; | |
import pick from 'lodash/object/pick'; | |
const {h1, div, p, a, button} = React.DOM; | |
const app = createApp(document.getElementById('app'), { | |
routes: [ | |
['viewUser', '/users/:id'], | |
['editUser', '/users/:id/edit'] |
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 mkElement(tag) { | |
return function () { | |
return React.createElement.apply(React, [tag].concat([].slice.call(arguments, 0))); | |
}; | |
} | |
var div = mkElement("div"); | |
var h1 = mkElement("h1"); |
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
// Most components are defined fully by their render function, | |
// and all they need to access is the props | |
var myComponent = createComponent(function (props) { | |
return React.DOM.h1({}, "Hello " + props.name); | |
}); | |
// ...which can be done very succinctly with ES6: | |
const {h1, div} = React.DOM; | |
const myComponent = createComponent(({name}) => h1({}, `Hello ${name}`)); |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="chrome=1"> | |
<meta http-equiv="X-UA-Compatible" content="edge"> | |
<title>Building static sites in Clojure with Stasis</title> | |
<meta name="author" content="Christian Johansen"> | |
<meta name="robots" content="all"> | |
<link href="http://feeds.feedburner.com/cjno-en" rel="alternate" type="application/rss+xml" title="cjohansen.no blog-feed"> |
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 appUI(actions) { | |
return React.createClass({ | |
render: function () { | |
return React.DOM.h1({onClick: actions.doit}, 'LOL'); | |
} | |
}); | |
} | |
var data = {} |
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 loginUI(actions) { | |
return React.createClass({ | |
render: function () {} | |
}); | |
} |
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 loginUI(actions) { | |
return React.createClass({ | |
render: function () {} | |
}); | |
} |
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 setPixelAspectRatio(ratio) { | |
var canvas = document.createElement('canvas'); | |
canvas.width = originalImage.width * ratio; | |
canvas.height = originalImage.height; | |
var ctx = canvas.getContext('2d'); | |
ctx.scale(ratio, 1); | |
ctx.drawImage(originalImage, 0, 0); | |
imageEditor.loadImage(canvas); | |
} |
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
.mod, .tabs, pre, h1, h2, h4, h5, p, ul, ol, hr, table {margin: 1rem 0;} | |
.bd, .media {overflow:hidden;} | |
.media .img {float:left; margin-right: 0;} | |
.media .imgExt {float:right; margin-left: 0;} |