Skip to content

Commit 86c6e49

Browse files
author
Nathan Hutchison
committed
flux-todomvc + some variations
1 parent acc9442 commit 86c6e49

File tree

4 files changed

+105
-1
lines changed

4 files changed

+105
-1
lines changed

examples/flux-todomvc/js/app.js

+51-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,57 @@ var React = require('react');
1111

1212
var TodoApp = require('./components/TodoApp.react');
1313

14+
// Stuff from Axolotl example :D
15+
16+
// hack to show the labs page before its enabled...
17+
// normally you would have a route to this page :D
18+
if (!localStorage.axoVariations) localStorage.axoVariations = '{show-labs-page: true}';
19+
20+
var Axo = require('axolotl');
21+
22+
var variationRequire = require.context('./variations', true, /\.js$/);
23+
var availableVariations = variationRequire.keys().map((v) => variationRequire(v).variation);
24+
25+
var Axo = require('axolotl');
26+
var axo = new Axo(availableVariations, undefined, Axo.localStorageActions);
27+
28+
var LabsPage = Axo.LabsPage;
29+
var LabsVariation = require('./variations/labs.js');
30+
31+
var AxoContext = React.createClass({
32+
childContextTypes: {
33+
axo: React.PropTypes.object.isRequired,
34+
},
35+
36+
getChildContext() {
37+
return {
38+
axo: axo,
39+
};
40+
},
41+
42+
getInitialState() {
43+
return {
44+
showLabs: false,
45+
};
46+
},
47+
48+
render() {
49+
return (
50+
<div>
51+
<LabsVariation onClick={() => this.setState({showLabs: !this.state.showLabs})}/>
52+
{ this.state.showLabs ?
53+
<LabsPage/>
54+
:
55+
<TodoApp/>
56+
}
57+
</div>
58+
);
59+
}
60+
});
61+
62+
// :D
63+
1464
React.render(
15-
<TodoApp />,
65+
<AxoContext/>,
1666
document.getElementById('todoapp')
1767
);

examples/flux-todomvc/js/components/TodoItem.react.js

+7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ var TodoTextInput = require('./TodoTextInput.react');
1414

1515
var classNames = require('classnames');
1616

17+
// Axolotl Variation :D
18+
19+
var ROFLVariation = require('../variations/rofl');
20+
21+
// :D
22+
1723
var TodoItem = React.createClass({
1824

1925
propTypes: {
@@ -62,6 +68,7 @@ var TodoItem = React.createClass({
6268
onChange={this._onToggleComplete}
6369
/>
6470
<label onDoubleClick={this._onDoubleClick}>
71+
<ROFLVariation/>
6572
{todo.text}
6673
</label>
6774
<button className="destroy" onClick={this._onDestroyClick} />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
var React = require('react');
2+
3+
var Axo = require('axolotl');
4+
5+
var LabsPage = React.createClass({
6+
render() {
7+
return (
8+
<div>
9+
<br/>
10+
<a href="#" onClick={this.props.onClick}>Toggle Labs Config</a>
11+
</div>
12+
);
13+
}
14+
});
15+
16+
17+
const LabsPageVariation = Axo.VariationEnhance({
18+
Component: LabsPage,
19+
name: 'show-labs-page',
20+
description: 'Add a link to configure the labs page',
21+
visible: true, // allow users to opt in should they choose
22+
});
23+
24+
module.exports = LabsPageVariation;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
var React = require('react');
2+
3+
var Axo = require('axolotl');
4+
5+
var ROFL = React.createClass({
6+
render() {
7+
return (
8+
<div>
9+
<img style={{width: 40}} src={`http://lorempixel.com/40/40/cats?${Math.random()}`}/>
10+
</div>
11+
);
12+
}
13+
});
14+
15+
16+
const ROFLVariation = Axo.VariationEnhance({
17+
Component: ROFL,
18+
name: 'rofl',
19+
description: 'Put a cat on it',
20+
visible: true, // allow users to opt in should they choose
21+
});
22+
23+
module.exports = ROFLVariation;

0 commit comments

Comments
 (0)