Skip to content

Instantly share code, notes, and snippets.

@farism
Created June 30, 2017 19:06
Show Gist options
  • Save farism/61b0adcfc1f17b76a68d93c5edd739b8 to your computer and use it in GitHub Desktop.
Save farism/61b0adcfc1f17b76a68d93c5edd739b8 to your computer and use it in GitHub Desktop.
const gridView = (
rowHeight,
numCols,
deleteTile,
updateLayout,
setDrilldown,
isSidebarOpen,
tiles,
) => (
<AutoSizedReactGridLayout
className="layout"
cols={numCols}
isDraggable={isSidebarOpen}
isResizable={isSidebarOpen}
layout={null}
margin={[16, 16]}
onDragStop={(layout, { x, y }, { x: newX, y: newY }) => {
if (newX !== x || newY !== y) {
updateLayout(layout);
setTimeout(resize, 50);
}
}}
onResizeStop={(layout, { w, h }, { w: newW, h: newH }) => {
if (newW !== w || newH !== h) {
updateLayout(layout);
setTimeout(resize, 50);
}
}}
onResize={() => {
setTimeout(resize, 250);
}}
rowHeight={rowHeight || 400}
>
{tiles.map(tile => (
<div
key={tile.get('chart_id').toString()}
data-grid={tile.get('layout').toJS()}
styleName="grid-item"
>
{tileView(deleteTile, setDrilldown, isSidebarOpen, tile)}
</div>
))}
</AutoSizedReactGridLayout>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment