diff --git a/.github/images/purple-selected-option-dark.png b/.github/images/purple-selected-option-dark.png index 5ce44d3..41078d4 100644 Binary files a/.github/images/purple-selected-option-dark.png and b/.github/images/purple-selected-option-dark.png differ diff --git a/.github/images/purple-selected-option-light.png b/.github/images/purple-selected-option-light.png index 9c53c91..5a5d7ab 100644 Binary files a/.github/images/purple-selected-option-light.png and b/.github/images/purple-selected-option-light.png differ diff --git a/README.md b/README.md index 0756a71..f872555 100644 --- a/README.md +++ b/README.md @@ -344,7 +344,13 @@ If you choose to stick with the default `selectedOptionStyle="color"`, you have one additional styling option. If you do not like the default of blue for the highlight color, you can pass the `selectedOptionColorPalette` prop to change it. This prop will accept any named color from your theme's color palette, and -it will use the `500` value in light mode or the `300` value in dark mode. +it will use `colorPalette.solid` for the background, and `colorPalette.contrast` +for the text. + +If you'd like to use a custom color palette for this prop, ensure that you have +properly set up the custom color, including the `solid` and `contrast` semantic +tokens, accoring to +[the official guide](https://www.chakra-ui.com/guides/theming-custom-colors). > [!NOTE] > diff --git a/demo/eslint.config.js b/demo/eslint.config.js index b64bf09..aee2b69 100644 --- a/demo/eslint.config.js +++ b/demo/eslint.config.js @@ -25,6 +25,13 @@ const eslintConfig = tseslint.config( ...react.configs.recommended.rules, ...react.configs["jsx-runtime"].rules, ...reactHooks.configs.recommended.rules, + "@typescript-eslint/consistent-type-imports": [ + "warn", + { + prefer: "type-imports", + disallowTypeAnnotations: true, + }, + ], "react/prop-types": "off", "react-refresh/only-export-components": [ "warn", diff --git a/demo/src/app.tsx b/demo/src/app.tsx index e9c363b..f18c048 100644 --- a/demo/src/app.tsx +++ b/demo/src/app.tsx @@ -10,16 +10,16 @@ import { Stack, Text, } from "@chakra-ui/react"; +import type { GroupBase, LoadingIndicatorProps } from "chakra-react-select"; import { AsyncSelect, CreatableSelect, - GroupBase, - LoadingIndicatorProps, Select, chakraComponents, } from "chakra-react-select"; import ConnectedSelectMenuExample from "./components/advanced-examples/connected-select-menu-example"; import CustomIndicatorIconsExample from "./components/advanced-examples/custom-indicator-icons-example"; +import DynamicSelectedOptionColorExample from "./components/advanced-examples/dynamic-selected-option-color-example"; import MenuPortalTargetExample from "./components/advanced-examples/menu-portal-target-example"; import OptionsWithIconsExample from "./components/advanced-examples/options-with-icons-example"; import SelectPopoverExample from "./components/advanced-examples/select-popover-example"; @@ -35,7 +35,8 @@ import { SelectValueText, } from "./components/ui/select"; import animeMovies from "./data/anime-movies"; -import { ColorOption, colorOptions, groupedOptions } from "./data/options"; +import type { ColorOption } from "./data/options"; +import { colorOptions, groupedOptions } from "./data/options"; const mappedColorOptions = colorOptions.map((option) => ({ ...option, @@ -354,6 +355,16 @@ const App = () => { /> + + Single Select with dynamic selectedOptionColorPalette + + } + > + + + diff --git a/demo/src/components/advanced-examples/custom-indicator-icons-example.tsx b/demo/src/components/advanced-examples/custom-indicator-icons-example.tsx index be0ba67..e633538 100644 --- a/demo/src/components/advanced-examples/custom-indicator-icons-example.tsx +++ b/demo/src/components/advanced-examples/custom-indicator-icons-example.tsx @@ -1,9 +1,5 @@ -import { - GroupBase, - Select, - SelectComponentsConfig, - chakraComponents, -} from "chakra-react-select"; +import type { GroupBase, SelectComponentsConfig } from "chakra-react-select"; +import { Select, chakraComponents } from "chakra-react-select"; import { LuArrowDown, LuCircleX } from "react-icons/lu"; import { groupedOptions } from "../../data/options"; diff --git a/demo/src/components/advanced-examples/dynamic-selected-option-color-example.tsx b/demo/src/components/advanced-examples/dynamic-selected-option-color-example.tsx new file mode 100644 index 0000000..0d82798 --- /dev/null +++ b/demo/src/components/advanced-examples/dynamic-selected-option-color-example.tsx @@ -0,0 +1,23 @@ +import { useState } from "react"; +import { Select } from "chakra-react-select"; +import type { ColorOption } from "../../data/options"; +import { colorOptions } from "../../data/options"; + +const DynamicSelectedOptionColorExample = () => { + const [selectedOptionColorPalette, setSelectedOptionColorPalette] = + useState(colorOptions[0]); + + return ( +