-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatic-container.jsx
42 lines (34 loc) · 1.08 KB
/
static-container.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
39
40
41
42
import React from 'react';
export default (Component, opts) => {
const Container = class Container extends React.Component {
constructor(props) {
super(props);
this.getStyles = this.getStyles.bind(this);
}
getStyles() {
const defaultStylePaths = [];
if (Component.displayName) {
defaultStylePaths.push(`${Component.displayName}.css`);
}
const consumerDefinedStyles = opts && opts.styles
? opts.styles(this.props, this.state)
: [];
return {
componentName: Component.displayName
? Component.displayName
: '',
stylePaths: [].concat(
defaultStylePaths, consumerDefinedStyles
)
};
}
render() {
const safeProps = {
...this.props,
};
return <Component {...safeProps} />;
}
};
Container.displayName = 'StaticCSS';
return Container;
};