Added shared grid context and moved away from calling useContext directly

This commit is contained in:
Mitchell McCaffrey
2021-02-06 13:32:38 +11:00
parent 8991be923e
commit f20173de35
60 changed files with 672 additions and 460 deletions
+6 -2
View File
@@ -10,6 +10,8 @@ import useDataSource from "../../hooks/useDataSource";
import useImageCenter from "../../hooks/useImageCenter";
import useResponsiveLayout from "../../hooks/useResponsiveLayout";
import { GridProvider } from "../../contexts/GridContext";
import GridOnIcon from "../../icons/GridOnIcon";
import GridOffIcon from "../../icons/GridOffIcon";
@@ -110,7 +112,7 @@ function TokenPreview({ token }) {
/>
{showGridPreview && (
<Group offsetY={gridHeight - tokenHeight}>
<Grid
<GridProvider
grid={{
size: { x: gridX, y: gridY },
inset: {
@@ -121,7 +123,9 @@ function TokenPreview({ token }) {
}}
width={gridWidth}
height={gridHeight}
/>
>
<Grid />
</GridProvider>
<Rect
width={gridWidth}
height={gridHeight}