diff --git a/package.json b/package.json index 97e36eb..e1084c1 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "react-router-dom": "^5.1.2", "react-router-hash-link": "^1.2.2", "react-scripts": "3.4.0", + "react-select": "^3.1.0", "react-spring": "^8.0.27", "react-use-gesture": "^7.0.15", "shortid": "^2.2.15", diff --git a/src/components/Select.js b/src/components/Select.js new file mode 100644 index 0000000..44b0dad --- /dev/null +++ b/src/components/Select.js @@ -0,0 +1,57 @@ +import React from "react"; +import ReactSelect from "react-select"; +import { useThemeUI } from "theme-ui"; + +function Select(props) { + const { theme } = useThemeUI(); + + function getColor(state) { + return state.isDisabled ? theme.colors.gray : theme.colors.text; + } + + return ( + ({ + ...provided, + backgroundColor: theme.colors.background, + color: getColor(state), + borderRadius: "4px", + borderColor: theme.colors.gray, + borderStyle: "solid", + borderWidth: "1px", + }), + control: (provided, state) => ({ + ...provided, + backgroundColor: theme.colors.background, + color: getColor(state), + borderColor: theme.colors.text, + }), + singleValue: (provided, state) => ({ + ...provided, + color: getColor(state), + }), + dropdownIndicator: (provided, state) => ({ + ...provided, + color: getColor(state), + ":hover": { + color: state.isDisabled ? theme.colors.gray : theme.colors.primary, + }, + }), + }} + theme={(t) => ({ + ...t, + colors: { + ...t.colors, + primary: theme.colors.primary, + primary50: theme.colors.secondary, + primary25: theme.colors.highlight, + }, + })} + {...props} + /> + ); +} + +export default Select; diff --git a/src/components/map/MapSettings.js b/src/components/map/MapSettings.js index 6e12cff..f843716 100644 --- a/src/components/map/MapSettings.js +++ b/src/components/map/MapSettings.js @@ -1,26 +1,19 @@ import React from "react"; -import { - Flex, - Box, - Label, - Input, - Checkbox, - IconButton, - Select, -} from "theme-ui"; +import { Flex, Box, Label, Input, Checkbox, IconButton } from "theme-ui"; import ExpandMoreIcon from "../../icons/ExpandMoreIcon"; import { isEmpty } from "../../helpers/shared"; import Divider from "../Divider"; +import Select from "../Select"; const qualitySettings = [ - { id: "low", name: "Low" }, - { id: "medium", name: "Medium" }, - { id: "high", name: "High" }, - { id: "ultra", name: "Ultra High" }, - { id: "original", name: "Original" }, + { value: "low", label: "Low" }, + { value: "medium", label: "Medium" }, + { value: "high", label: "High" }, + { value: "ultra", label: "Ultra High" }, + { value: "original", label: "Original" }, ]; function MapSettings({ @@ -105,16 +98,17 @@ function MapSettings({ mb={mapEmpty || map.type === "default" ? 2 : 0} sx={{ alignItems: "flex-end" }} > - - + + + defaultValue={{ value: "square", label: "Square" }} + isDisabled={mapEmpty || map.type === "default"} + options={[ + { value: "square", label: "Square" }, + { value: "hex", label: "Hex (Coming Soon)" }, + ]} + isOptionDisabled={(option) => option.value === "hex"} + /> {!mapEmpty && map.type !== "default" && ( - - + + + options={qualitySettings} + value={ + !mapEmpty && + qualitySettings.find((s) => s.value === map.quality) + } + isDisabled={mapEmpty} + onChange={(option) => + onSettingsChange("quality", option.value) + } + isOptionDisabled={(option) => + mapEmpty || + (option.value !== "original" && + !map.resolutions[option.value]) + } + /> - - + + + options={categorySettings} + value={ + !tokenEmpty && + categorySettings.find((s) => s.value === token.category) + } + isDisabled={tokenEmpty || token.type === "default"} + onChange={(option) => + onSettingsChange("category", option.value) + } + />