-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
52 lines (42 loc) · 1.15 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var React = require('react');
var Router = require('react-router');
var DemoLightbox = React.createClass({
render: function() {
return <div>I'm a lightbox!</div>;
}
});
var lightboxes = {
'demoLightbox': DemoLightbox
};
var RoutedLightbox = React.createClass({
mixins: [Router.State],
render: function() {
var query = this.getQuery();
if (!query['lightbox'] || !lightboxes[query['lightbox']]) {
return null;
}
return (
<div>
<div className="background" />
<div className="lightbox">
{React.createElement(lightboxes[query['lightbox']])}
</div>
</div>
);
}
});
var EmptyHandler = React.createClass({
render: function() {
return null;
}
});
var routes = (
<Router.Route name="lightbox" path="/" handler={RoutedLightbox}>
<Router.NotFoundRoute handler={EmptyHandler} />
</Router.Route>
);
var div = document.createElement('div');
Router.run(routes, Router.HistoryLocation, function(Handler) {
React.render(<Handler />, div);
});
document.body.appendChild(div);