Created
February 22, 2015 04:08
-
-
Save StoneCypher/66c78ab8c12e9e25a7bc to your computer and use it in GitHub Desktop.
This file contains hidden or 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> | |
| <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