Added creatable option to Select

This commit is contained in:
Mitchell McCaffrey
2020-10-01 15:04:45 +10:00
parent 99b2bd0240
commit 1938f59060
3 changed files with 12 additions and 3 deletions

View File

@@ -1,17 +1,19 @@
import React from "react";
import ReactSelect from "react-select";
import Creatable from "react-select/creatable";
import { useThemeUI } from "theme-ui";
function Select(props) {
function Select({ creatable, ...props }) {
const { theme } = useThemeUI();
function getColor(state) {
return state.isDisabled ? theme.colors.gray : theme.colors.text;
}
const Component = creatable ? Creatable : ReactSelect;
return (
<ReactSelect
isSearchable={false}
<Component
styles={{
menu: (provided, state) => ({
...provided,
@@ -39,6 +41,10 @@ function Select(props) {
color: state.isDisabled ? theme.colors.gray : theme.colors.primary,
},
}),
input: (provided, state) => ({
...provided,
color: getColor(state),
}),
}}
theme={(t) => ({
...t,