import React from 'react'; import PropTypes from 'prop-types'; import { Modal, ModalHeader, ModalBody, ModalFooter, } from 'reactstrap'; import BootstrapGrid from '../../models/BootstrapGrid'; export default class GridEditModal extends React.PureComponent { constructor(props) { super(props); this.state = { show: false, gridHtml: '', }; this.init = this.init.bind(this); this.show = this.show.bind(this); this.hide = this.hide.bind(this); this.cancel = this.cancel.bind(this); this.pasteCodedGrid = this.pasteCodedGrid.bind(this); } init(gridHtml) { const initGridHtml = gridHtml; this.setState({ gridHtml: initGridHtml }, function() { // display gridHtml for re-editing console.log(this.state.gridHtml); }); } show(gridHtml) { this.init(gridHtml); this.setState({ show: true }); const test = new BootstrapGrid([1, 11], 'md'); const test1 = new BootstrapGrid([2, 10], 'dd'); console.log(test.responsiveSize); console.log(test1.responsiveSize); } hide() { this.setState({ show: false }); } cancel() { this.hide(); } pasteCodedGrid() { // dummy data const pastedGridData = `::: editable-row\n
\n
dummy
\n
\n
\n:::`; if (this.props.onSave != null) { this.props.onSave(pastedGridData); } this.cancel(); } showBgCols() { const cols = []; for (let i = 0; i < 12; i++) { // [bg-light:TODO support dark mode by GW-3037] cols.push(
); } return cols; } showEditableCols() { const cols = []; for (let i = 0; i < 12; i++) { // [bg-light:TODO support dark mode by GW-3037] cols.push(
); } return cols; } render() { return ( Edit Grid
Phone
Tablet
Desktop
Large Desktop
{this.showBgCols()}
{/* [Just an example to check if bg-cols and editable-cols fit] */}
); } } GridEditModal.propTypes = { onSave: PropTypes.func, };