diff --git a/src/Layout.tsx b/src/Layout.tsx index 8c627d2..d8acb44 100644 --- a/src/Layout.tsx +++ b/src/Layout.tsx @@ -1,10 +1,9 @@ -import React from "react"; +import React, { useContext, FunctionComponent } from "react"; import { makeStyles } from "@material-ui/core/styles"; import { Typography } from "@material-ui/core"; import { createLayoutComponent } from "./constraints/generator"; import { vertices } from "./examples/vertices"; - -const Comp = createLayoutComponent(vertices); +import { LayoutContext, LayoutProvider } from "./LayoutContext"; const F = ""; @@ -56,43 +55,62 @@ const useStyles = makeStyles({ } }); -export const Layout: React.FC = () => { - const classes = useStyles(); +const ComponentList: FunctionComponent<{ box: string; item: string }> = ({ + box, + item +}) => { + const { layout, addComponent } = useContext(LayoutContext); + return ( -
-
-
- - Components - -
-
- - HeaderXStyleB - -
-
- - HeaderXStyleBasd + <> + {Object.keys(layout).map(name => ( +
+ + {name}
-
- - AJGS - + ))} + + addComponent( + [...Array(10)] + .map(i => (~~(Math.random() * 36)).toString(36)) + .join("") + ) + } + > + Add component + + + ); +}; + +const ComponentView = () => { + const { layout, addComponent } = useContext(LayoutContext); + const Comp = createLayoutComponent(layout); + return ; +}; + +export const Layout: React.FC = () => { + const classes = useStyles(); + return ( + +
+
+
+ + Components + +
+
-
- - SuperLargeTextXDXDXDXDXDXDXDXXDXDXD - +
+
-
- -
-
+
); };