Files
grungnet/src/components/map/MapTiles.js

100 lines
2.4 KiB
JavaScript
Raw Normal View History

import React, { useContext } from "react";
import { Flex, Box, Text } from "theme-ui";
2020-04-25 00:42:23 +10:00
import SimpleBar from "simplebar-react";
import AddIcon from "../../icons/AddIcon";
import MapTile from "./MapTile";
import Link from "../Link";
import DatabaseContext from "../../contexts/DatabaseContext";
function MapTiles({
maps,
selectedMap,
selectedMapState,
onMapSelect,
onMapAdd,
onMapRemove,
onMapReset,
onDone,
}) {
const { databaseStatus } = useContext(DatabaseContext);
return (
<Box sx={{ position: "relative" }}>
<SimpleBar style={{ maxHeight: "300px", width: "500px" }}>
2020-04-25 00:42:23 +10:00
<Flex
py={2}
bg="muted"
2020-04-25 00:42:23 +10:00
sx={{
flexWrap: "wrap",
width: "500px",
2020-04-25 00:42:23 +10:00
borderRadius: "4px",
}}
>
<Flex
onClick={onMapAdd}
sx={{
":hover": {
color: "primary",
},
":focus": {
outline: "none",
},
":active": {
color: "secondary",
},
width: "150px",
height: "150px",
borderRadius: "4px",
justifyContent: "center",
alignItems: "center",
cursor: "pointer",
}}
m={2}
bg="muted"
aria-label="Add Map"
title="Add Map"
>
<AddIcon large />
</Flex>
{maps.map((map) => (
<MapTile
key={map.id}
map={map}
mapState={
selectedMap && map.id === selectedMap.id && selectedMapState
}
isSelected={selectedMap && map.id === selectedMap.id}
onMapSelect={onMapSelect}
onMapRemove={onMapRemove}
onMapReset={onMapReset}
onDone={onDone}
/>
))}
2020-04-25 00:42:23 +10:00
</Flex>
</SimpleBar>
{databaseStatus === "disabled" && (
<Box
sx={{
position: "absolute",
top: 0,
left: 0,
right: 0,
textAlign: "center",
}}
bg="highlight"
p={1}
>
<Text as="p" variant="body2">
2020-05-03 18:30:01 +10:00
Map saving is unavailable. See <Link to="/faq#saving">FAQ</Link> for
more information.
</Text>
</Box>
)}
</Box>
);
}
export default MapTiles;