forked from WikiEducationFoundation/WikiEduDashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
expandable.jsx
38 lines (32 loc) · 824 Bytes
/
expandable.jsx
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
import React from 'react';
import UIActions from '../../actions/ui_actions.js';
import UIStore from '../../stores/ui_store.js';
const Expandable = function (Component) {
return React.createClass({
displayName: 'Expandable',
mixins: [UIStore.mixin],
getInitialState() {
return { is_open: false };
},
storeDidChange() {
this.setState({
is_open: UIStore.getOpenKey() === this.refs.component.getKey()
});
},
open(e) {
if (e !== null) { e.stopPropagation(); }
return UIActions.open(this.refs.component.getKey());
},
render() {
return (
<Component
{...this.state} {...this.props}
open={this.open}
stop={this.stop}
ref={'component'}
/>
);
}
});
};
export default Expandable;