import React from "react"; import ReactDOM from "react-dom"; import "style-loader!css-loader!../css/styles.css"; import "style-loader!css-loader!../examples/util/example-styles.css"; typeof window !== "undefined" && (window.React = React); // for devtools export default function makeLayout(Layout) { // Basic layout that mirrors the internals of its child layout by listening to `onLayoutChange`. // It does not pass any other props to the Layout. class ListeningLayout extends React.Component { state = { layout: [] }; onLayoutChange = layout => { this.setState({ layout: layout }); }; stringifyLayout() { return this.state.layout.map(function (l) { const name = l.i === "__dropping-elem__" ? "drop" : l.i; return (
{name} {`: [${l.x}, ${l.y}, ${l.w}, ${l.h}]`}
); }); } render() { return (
Displayed as [x, y, w, h]:
{this.stringifyLayout()}
); } } function run() { const contentDiv = document.getElementById("content"); const gridProps = window.gridProps || {}; ReactDOM.render( React.createElement(ListeningLayout, gridProps), contentDiv ); } if (!document.getElementById("content")) { document.addEventListener("DOMContentLoaded", run); } else { run(); } return ListeningLayout; }