EditorTabBody.tsx 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import React, { PureComponent } from 'react';
  2. import CustomScrollbar from 'app/core/components/CustomScrollbar/CustomScrollbar';
  3. import { FadeIn } from 'app/core/components/Animations/FadeIn';
  4. interface Props {
  5. children: JSX.Element;
  6. heading: string;
  7. renderToolbar: () => JSX.Element;
  8. }
  9. interface State {
  10. fadeIn: boolean;
  11. }
  12. export class EditorTabBody extends PureComponent<Props, State> {
  13. constructor(props) {
  14. super(props);
  15. this.state = {
  16. fadeIn: false,
  17. };
  18. }
  19. componentDidMount() {
  20. this.setState({ fadeIn: true });
  21. }
  22. // renderMainSelection(view: EditorToolBarView) {
  23. // return (
  24. // <div className="toolbar__main" onClick={() => this.onToggleToolBarView(view)} key={view.title + view.icon}>
  25. // <img className="toolbar__main-image" src={view.imgSrc} />
  26. // <div className="toolbar__main-name">{view.title}</div>
  27. // <i className="fa fa-caret-down" />
  28. // </div>
  29. // );
  30. // }
  31. //
  32. // renderButton(view: EditorToolBarView) {
  33. // const onClick = () => {
  34. // if (view.onClick) {
  35. // view.onClick();
  36. // }
  37. // this.onToggleToolBarView(view);
  38. // };
  39. //
  40. // return (
  41. // <div className="nav-buttons" key={view.title + view.icon}>
  42. // <button className="btn navbar-button" onClick={onClick} disabled={view.disabled}>
  43. // {view.icon && <i className={view.icon} />} {view.title}
  44. // </button>
  45. // </div>
  46. // );
  47. // }
  48. //
  49. // renderOpenView(view: EditorToolBarView) {
  50. // return (
  51. // <div className="toolbar-subview">
  52. // <button className="toolbar-subview__close" onClick={this.onCloseOpenView}>
  53. // <i className="fa fa-chevron-up" />
  54. // </button>
  55. // {view.render(this.onCloseOpenView)}
  56. // </div>
  57. // );
  58. // }
  59. render() {
  60. const { children, renderToolbar, heading } = this.props;
  61. const { fadeIn } = this.state;
  62. return (
  63. <>
  64. <div className="toolbar">
  65. <div className="toolbar__heading">{heading}</div>
  66. {renderToolbar && renderToolbar()}
  67. </div>
  68. <div className="panel-editor__scroll">
  69. <CustomScrollbar autoHide={false}>
  70. <div className="panel-editor__content">
  71. <FadeIn in={fadeIn} duration={50}>
  72. {children}
  73. </FadeIn>
  74. </div>
  75. </CustomScrollbar>
  76. </div>
  77. </>
  78. );
  79. }
  80. }