2020-05-20 12:37:29 +10:00
|
|
|
import React from "react";
|
2020-09-23 16:29:15 +10:00
|
|
|
import { Flex, Box, Input, IconButton, Label, Checkbox } from "theme-ui";
|
2020-05-20 12:37:29 +10:00
|
|
|
|
|
|
|
|
import ExpandMoreIcon from "../../icons/ExpandMoreIcon";
|
2020-06-28 15:44:36 +10:00
|
|
|
import { isEmpty } from "../../helpers/shared";
|
2020-05-20 12:37:29 +10:00
|
|
|
|
2020-09-23 16:29:15 +10:00
|
|
|
import Select from "../Select";
|
|
|
|
|
|
2020-08-27 19:09:16 +10:00
|
|
|
const categorySettings = [
|
2020-09-23 16:29:15 +10:00
|
|
|
{ value: "character", label: "Character" },
|
|
|
|
|
{ value: "prop", label: "Prop" },
|
|
|
|
|
{ value: "vehicle", label: "Vehicle / Mount" },
|
2020-08-27 19:09:16 +10:00
|
|
|
];
|
|
|
|
|
|
2020-05-20 12:37:29 +10:00
|
|
|
function TokenSettings({
|
|
|
|
|
token,
|
|
|
|
|
onSettingsChange,
|
|
|
|
|
showMore,
|
|
|
|
|
onShowMoreChange,
|
|
|
|
|
}) {
|
2020-06-28 15:44:36 +10:00
|
|
|
const tokenEmpty = !token || isEmpty(token);
|
2020-05-20 12:37:29 +10:00
|
|
|
return (
|
|
|
|
|
<Flex sx={{ flexDirection: "column" }}>
|
|
|
|
|
<Flex>
|
|
|
|
|
<Box mt={2} sx={{ flexGrow: 1 }}>
|
|
|
|
|
<Label htmlFor="tokenSize">Default Size</Label>
|
|
|
|
|
<Input
|
|
|
|
|
type="number"
|
|
|
|
|
name="tokenSize"
|
2020-08-07 13:56:03 +10:00
|
|
|
value={`${(token && token.defaultSize) || 0}`}
|
2020-05-20 12:37:29 +10:00
|
|
|
onChange={(e) =>
|
|
|
|
|
onSettingsChange("defaultSize", parseInt(e.target.value))
|
|
|
|
|
}
|
2020-06-28 15:44:36 +10:00
|
|
|
disabled={tokenEmpty || token.type === "default"}
|
2020-05-20 12:37:29 +10:00
|
|
|
min={1}
|
|
|
|
|
my={1}
|
|
|
|
|
/>
|
|
|
|
|
</Box>
|
|
|
|
|
</Flex>
|
|
|
|
|
{showMore && (
|
|
|
|
|
<>
|
2020-05-22 20:43:07 +10:00
|
|
|
<Box mt={2} sx={{ flexGrow: 1 }}>
|
2020-05-20 12:37:29 +10:00
|
|
|
<Label htmlFor="name">Name</Label>
|
|
|
|
|
<Input
|
|
|
|
|
name="name"
|
|
|
|
|
value={(token && token.name) || ""}
|
|
|
|
|
onChange={(e) => onSettingsChange("name", e.target.value)}
|
2020-06-28 15:44:36 +10:00
|
|
|
disabled={tokenEmpty || token.type === "default"}
|
2020-05-20 12:37:29 +10:00
|
|
|
my={1}
|
|
|
|
|
/>
|
|
|
|
|
</Box>
|
2020-05-28 16:23:20 +10:00
|
|
|
<Flex my={2}>
|
2020-09-23 16:29:15 +10:00
|
|
|
<Box mb={1} sx={{ flexGrow: 1 }}>
|
|
|
|
|
<Label mb={1}>Category</Label>
|
2020-08-27 19:09:16 +10:00
|
|
|
<Select
|
2020-09-23 16:29:15 +10:00
|
|
|
options={categorySettings}
|
|
|
|
|
value={
|
|
|
|
|
!tokenEmpty &&
|
|
|
|
|
categorySettings.find((s) => s.value === token.category)
|
|
|
|
|
}
|
|
|
|
|
isDisabled={tokenEmpty || token.type === "default"}
|
|
|
|
|
onChange={(option) =>
|
|
|
|
|
onSettingsChange("category", option.value)
|
|
|
|
|
}
|
2020-10-01 15:04:45 +10:00
|
|
|
isSearchable={false}
|
2020-09-23 16:29:15 +10:00
|
|
|
/>
|
2020-05-28 16:23:20 +10:00
|
|
|
</Box>
|
2020-08-27 19:09:16 +10:00
|
|
|
<Flex sx={{ flexGrow: 1, alignItems: "center" }} ml={2}>
|
2020-05-28 16:23:20 +10:00
|
|
|
<Label>
|
|
|
|
|
<Checkbox
|
|
|
|
|
checked={token && token.hideInSidebar}
|
2020-06-28 15:44:36 +10:00
|
|
|
disabled={tokenEmpty || token.type === "default"}
|
2020-05-28 16:23:20 +10:00
|
|
|
onChange={(e) =>
|
|
|
|
|
onSettingsChange("hideInSidebar", e.target.checked)
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
Hide in Sidebar
|
|
|
|
|
</Label>
|
2020-08-27 19:09:16 +10:00
|
|
|
</Flex>
|
2020-05-28 16:23:20 +10:00
|
|
|
</Flex>
|
2020-05-20 12:37:29 +10:00
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
<IconButton
|
|
|
|
|
onClick={(e) => {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
onShowMoreChange(!showMore);
|
|
|
|
|
}}
|
|
|
|
|
sx={{
|
|
|
|
|
transform: `rotate(${showMore ? "180deg" : "0"})`,
|
|
|
|
|
alignSelf: "center",
|
|
|
|
|
}}
|
|
|
|
|
aria-label={showMore ? "Show Less" : "Show More"}
|
|
|
|
|
title={showMore ? "Show Less" : "Show More"}
|
|
|
|
|
>
|
|
|
|
|
<ExpandMoreIcon />
|
|
|
|
|
</IconButton>
|
|
|
|
|
</Flex>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default TokenSettings;
|