Skip to content

Instantly share code, notes, and snippets.

@StoneCypher
Created February 22, 2015 04:08
Show Gist options
  • Select an option

  • Save StoneCypher/66c78ab8c12e9e25a7bc to your computer and use it in GitHub Desktop.

Select an option

Save StoneCypher/66c78ab8c12e9e25a7bc to your computer and use it in GitHub Desktop.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Example Spinner App</title>
<style type="text/css">
body { font-size: 600%; font-family: helvetica neue, sans-serif; }
button { font-size: 50%; margin: 2em; }
</style>
<script defer src="http://fb.me/JSXTransformer-0.12.2.js"></script>
<script defer src="http://fb.me/react-0.12.2.js"></script>
<script defer src="http://cdnjs.cloudflare.com/ajax/libs/flocks.js/0.15.1/flocks.js"></script>
<script defer type="text/jsx">
// up button control
var Up = flocks.createClass({
inc: function() { this.fset('value', this.fctx['value'] + 1) },
render: function() { return <button onClick={this.inc}>▲</button>; }
});
// down button control
var Down = flocks.createClass({
dec: function() { this.fset('value', this.fctx['value'] - 1) },
render: function() { return <button onClick={this.dec}>▼</button>; }
});
// the application root control
var SpinnerApp = flocks.createClass({
render: function() { return <div><Up/>{this.fctx['value']}<Down/></div>; }
});
// telling flocks where to put the app control, and what that control is
var FlocksConfig = { target: document.body, control: SpinnerApp };
var InitialState = { value: 0 };
// and mount the app 😄
flocks.mount(FlocksConfig, InitialState);
</script>
</head>
<body></body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment