From d55514ef7c77507ce9f00355d663c8f64f1f2e36 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Tue, 25 May 2021 16:56:37 +1000 Subject: [PATCH] Refactor map and token image --- .../map/{MapTileImage.js => MapImage.js} | 6 +++--- src/components/map/MapTile.js | 4 ++-- src/components/map/MapTileGroup.js | 4 ++-- src/components/token/ListToken.js | 17 ++++------------- .../token/{TokenTileImage.js => TokenImage.js} | 8 ++++---- src/components/token/TokenTile.js | 4 ++-- src/components/token/TokenTileGroup.js | 4 ++-- 7 files changed, 19 insertions(+), 28 deletions(-) rename src/components/map/{MapTileImage.js => MapImage.js} (74%) rename src/components/token/{TokenTileImage.js => TokenImage.js} (68%) diff --git a/src/components/map/MapTileImage.js b/src/components/map/MapImage.js similarity index 74% rename from src/components/map/MapTileImage.js rename to src/components/map/MapImage.js index 037baba..0310487 100644 --- a/src/components/map/MapTileImage.js +++ b/src/components/map/MapImage.js @@ -4,7 +4,7 @@ import { Image } from "theme-ui"; import { useDataURL } from "../../contexts/AssetsContext"; import { mapSources as defaultMapSources } from "../../maps"; -function MapTileImage({ map, sx }) { +const MapTileImage = React.forwardRef(({ map, ...props }) => { const mapURL = useDataURL( map, defaultMapSources, @@ -12,7 +12,7 @@ function MapTileImage({ map, sx }) { map.type === "file" ); - return ; -} + return ; +}); export default MapTileImage; diff --git a/src/components/map/MapTile.js b/src/components/map/MapTile.js index c30c4c2..c061b19 100644 --- a/src/components/map/MapTile.js +++ b/src/components/map/MapTile.js @@ -1,7 +1,7 @@ import React from "react"; import Tile from "../tile/Tile"; -import MapTileImage from "./MapTileImage"; +import MapImage from "./MapImage"; function MapTile({ map, @@ -23,7 +23,7 @@ function MapTile({ badges={badges} editTitle="Edit Map" > - + ); } diff --git a/src/components/map/MapTileGroup.js b/src/components/map/MapTileGroup.js index 123e6c5..f556844 100644 --- a/src/components/map/MapTileGroup.js +++ b/src/components/map/MapTileGroup.js @@ -2,7 +2,7 @@ import React from "react"; import { Grid } from "theme-ui"; import Tile from "../tile/Tile"; -import MapTileImage from "./MapTileImage"; +import MapImage from "./MapImage"; import useResponsiveLayout from "../../hooks/useResponsiveLayout"; @@ -22,7 +22,7 @@ function MapTileGroup({ group, maps, isSelected, onSelect, onDoubleClick }) { sx={{ gridGap: 2 }} > {maps.slice(0, 9).map((map) => ( - - { const tokenURL = useDataURL( token, defaultTokenSources, @@ -13,7 +13,7 @@ function TokenTileImage({ token, sx }) { token.type === "file" ); - return ; -} + return ; +}); -export default TokenTileImage; +export default TokenImage; diff --git a/src/components/token/TokenTile.js b/src/components/token/TokenTile.js index 864cc7b..1146b24 100644 --- a/src/components/token/TokenTile.js +++ b/src/components/token/TokenTile.js @@ -1,7 +1,7 @@ import React from "react"; import Tile from "../tile/Tile"; -import TokenTileImage from "./TokenTileImage"; +import TokenImage from "./TokenImage"; function TokenTile({ token, @@ -21,7 +21,7 @@ function TokenTile({ badges={badges} editTitle="Edit Token" > - + ); } diff --git a/src/components/token/TokenTileGroup.js b/src/components/token/TokenTileGroup.js index 23776e5..abc5d00 100644 --- a/src/components/token/TokenTileGroup.js +++ b/src/components/token/TokenTileGroup.js @@ -2,7 +2,7 @@ import React from "react"; import { Grid } from "theme-ui"; import Tile from "../tile/Tile"; -import TokenTileImage from "./TokenTileImage"; +import TokenImage from "./TokenImage"; import useResponsiveLayout from "../../hooks/useResponsiveLayout"; @@ -29,7 +29,7 @@ function TokenTileGroup({ sx={{ gridGap: 2 }} > {tokens.slice(0, 9).map((token) => ( -