Moved to react-select for dropdowns to unify platforms

This commit is contained in:
Mitchell McCaffrey
2020-09-23 16:29:15 +10:00
parent 332de6433b
commit 2c0a01b66c
5 changed files with 169 additions and 72 deletions

57
src/components/Select.js Normal file
View File

@@ -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 (
<ReactSelect
isSearchable={false}
styles={{
menu: (provided, state) => ({
...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;