GridEditModal.jsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import {
  4. Modal, ModalHeader, ModalBody, ModalFooter,
  5. } from 'reactstrap';
  6. export default class GridEditModal extends React.PureComponent {
  7. constructor(props) {
  8. super(props);
  9. this.state = {
  10. show: false,
  11. };
  12. this.show = this.show.bind(this);
  13. this.hide = this.hide.bind(this);
  14. this.cancel = this.cancel.bind(this);
  15. this.pasteCodedGrid = this.pasteCodedGrid.bind(this);
  16. }
  17. show() {
  18. this.setState({ show: true });
  19. }
  20. hide() {
  21. this.setState({ show: false });
  22. }
  23. cancel() {
  24. this.hide();
  25. }
  26. pasteCodedGrid() {
  27. if (this.props.onSave != null) {
  28. this.props.onSave();
  29. }
  30. this.cancel();
  31. }
  32. showBgCols() {
  33. const cols = [];
  34. for (let i = 0; i < 12; i++) {
  35. cols.push(<div className="bg-light grid-bg-col col-1"></div>);
  36. }
  37. return cols;
  38. }
  39. // Get the already pasted code from the editor and expand it on the modal
  40. getPastedGrid(edited) {
  41. // When the cursor on editor is in row
  42. if (edited) {
  43. // Embed the html data in cols.
  44. }
  45. }
  46. render() {
  47. return (
  48. <Modal isOpen={this.state.show} toggle={this.cancel} size="xl">
  49. <ModalHeader tag="h4" toggle={this.cancel} className="bg-primary text-light">
  50. Edit Grid
  51. </ModalHeader>
  52. <ModalBody>
  53. <div className="container">
  54. <div className="row">
  55. <div className="col-3">
  56. <h5>Phone</h5>
  57. <div className="device-container"></div>
  58. <h5>Tablet</h5>
  59. <div className="device-container"></div>
  60. <h5>Desktop</h5>
  61. <div className="device-container"></div>
  62. <h5>Large Desktop</h5>
  63. <div className="device-container"></div>
  64. </div>
  65. <div className="row col-9 flex-nowrap overflow-auto">{this.showBgCols()}</div>
  66. </div>
  67. </div>
  68. </ModalBody>
  69. <ModalFooter className="grw-modal-footer">
  70. <div className="ml-auto">
  71. <button type="button" className="mr-2 btn btn-secondary" onClick={this.cancel}>Cancel</button>
  72. <button type="button" className="btn btn-primary" onClick={this.pasteCodedGrid}>Done</button>
  73. </div>
  74. </ModalFooter>
  75. </Modal>
  76. );
  77. }
  78. }
  79. GridEditModal.propTypes = {
  80. onSave: PropTypes.func,
  81. };