aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/collectionGrid/Grid.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2020-06-12 21:29:46 -0400
committerGitHub <noreply@github.com>2020-06-12 21:29:46 -0400
commit0636d49885f4d420a3d6cdc5f33d2bfda40e3db7 (patch)
treea4b1c01cbef56baf8a8c4143751998cfbebaf497 /src/client/views/collections/collectionGrid/Grid.tsx
parentc0f57178d79ec405a855bac82d6a12b6ae0dea27 (diff)
parent5c3edf121012ce789cf51d057b18f46fbc9b2d62 (diff)
Merge pull request #365 from browngraphicslab/grid_view_secondary
Grid view secondary
Diffstat (limited to 'src/client/views/collections/collectionGrid/Grid.tsx')
-rw-r--r--src/client/views/collections/collectionGrid/Grid.tsx53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/client/views/collections/collectionGrid/Grid.tsx b/src/client/views/collections/collectionGrid/Grid.tsx
new file mode 100644
index 000000000..3d2ed0cf9
--- /dev/null
+++ b/src/client/views/collections/collectionGrid/Grid.tsx
@@ -0,0 +1,53 @@
+import * as React from 'react';
+import { observer } from "mobx-react";
+
+import "../../../../../node_modules/react-grid-layout/css/styles.css";
+import "../../../../../node_modules/react-resizable/css/styles.css";
+
+import * as GridLayout from 'react-grid-layout';
+import { Layout } from 'react-grid-layout';
+export { Layout } from 'react-grid-layout';
+
+
+interface GridProps {
+ width: number;
+ nodeList: JSX.Element[] | null;
+ layout: Layout[] | undefined;
+ numCols: number;
+ rowHeight: number;
+ setLayout: (layout: Layout[]) => void;
+ transformScale: number;
+ childrenDraggable: boolean;
+ preventCollision: boolean;
+ compactType: string;
+ margin: number;
+}
+
+/**
+ * Wrapper around the actual GridLayout of `react-grid-layout`.
+ */
+@observer
+export default class Grid extends React.Component<GridProps> {
+ render() {
+ const compactType = this.props.compactType === "vertical" || this.props.compactType === "horizontal" ? this.props.compactType : null;
+ return (
+ <GridLayout className="layout"
+ layout={this.props.layout}
+ cols={this.props.numCols}
+ rowHeight={this.props.rowHeight}
+ width={this.props.width}
+ compactType={compactType}
+ isDroppable={true}
+ isDraggable={this.props.childrenDraggable}
+ isResizable={this.props.childrenDraggable}
+ useCSSTransforms={true}
+ onLayoutChange={this.props.setLayout}
+ preventCollision={this.props.preventCollision}
+ transformScale={1 / this.props.transformScale} // still doesn't work :(
+ margin={[this.props.margin, this.props.margin]}
+ >
+ {this.props.nodeList}
+ </GridLayout>
+ );
+ }
+}