Panel.js 619 B

1234567891011121314151617181920212223242526272829303132333435
  1. import React from 'react';
  2. import { pick } from '@utils';
  3. class Panel extends React.Component {
  4. static create = function (type) {
  5. return class TypedPanel extends Panel {
  6. constructor(props) {
  7. super(props, type);
  8. }
  9. };
  10. }
  11. constructor(props, type) {
  12. super(props);
  13. this.type = type;
  14. }
  15. render() {
  16. const { status, children } = this.props;
  17. const { type } = this;
  18. if (`${type}-selected` !== status) {
  19. return null;
  20. }
  21. return (
  22. <div {...pick(this.props, ['style', 'className'])}>
  23. {children}
  24. </div>
  25. );
  26. }
  27. }
  28. export default Panel;