Skip to content

Commit 57ef729

Browse files
committed
Move the placeholderColor prop out of the global props
1 parent e3a95c4 commit 57ef729

File tree

4 files changed

+27
-23
lines changed

4 files changed

+27
-23
lines changed

src/chakra-components/menu.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,16 @@ export const LoadingMessage = <
127127
className,
128128
cx,
129129
innerProps,
130-
selectProps: { size, placeholderColor, chakraStyles },
130+
selectProps: { size, chakraStyles },
131131
} = props;
132132

133+
/**
134+
* The chakra UI global placeholder color
135+
*
136+
* @see {@link https://github.com/chakra-ui/chakra-ui/blob/13c6d2e08b61e179773be4722bb81173dd599306/packages/theme/src/styles.ts#L13}
137+
*/
138+
const color = useColorModeValue("gray.400", "whiteAlpha.400");
139+
133140
const fontSizes: SizeProps = {
134141
sm: "0.875rem",
135142
md: "1rem",
@@ -143,7 +150,7 @@ export const LoadingMessage = <
143150
};
144151

145152
const initialStyles: SystemStyleObject = {
146-
color: placeholderColor,
153+
color,
147154
textAlign: "center",
148155
padding: paddings[size || "md"],
149156
fontSize: fontSizes[size || "md"],
@@ -182,9 +189,16 @@ export const NoOptionsMessage = <
182189
className,
183190
cx,
184191
innerProps,
185-
selectProps: { size, placeholderColor, chakraStyles },
192+
selectProps: { size, chakraStyles },
186193
} = props;
187194

195+
/**
196+
* The chakra UI global placeholder color
197+
*
198+
* @see {@link https://github.com/chakra-ui/chakra-ui/blob/13c6d2e08b61e179773be4722bb81173dd599306/packages/theme/src/styles.ts#L13}
199+
*/
200+
const color = useColorModeValue("gray.400", "whiteAlpha.400");
201+
188202
const fontSizes: SizeProps = {
189203
sm: "0.875rem",
190204
md: "1rem",
@@ -198,7 +212,7 @@ export const NoOptionsMessage = <
198212
};
199213

200214
const initialStyles: SystemStyleObject = {
201-
color: placeholderColor,
215+
color,
202216
textAlign: "center",
203217
padding: paddings[size || "md"],
204218
fontSize: fontSizes[size || "md"],

src/chakra-components/placeholder.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from "react";
22
import { Box } from "@chakra-ui/layout";
33
import type { SystemStyleObject } from "@chakra-ui/system";
4+
import { useColorModeValue } from "@chakra-ui/system";
45
import type { GroupBase, PlaceholderProps } from "react-select";
56

67
const Placeholder = <
@@ -15,9 +16,16 @@ const Placeholder = <
1516
className,
1617
cx,
1718
innerProps,
18-
selectProps: { placeholderColor, chakraStyles },
19+
selectProps: { chakraStyles },
1920
} = props;
2021

22+
/**
23+
* The chakra UI global placeholder color
24+
*
25+
* @see {@link https://github.com/chakra-ui/chakra-ui/blob/13c6d2e08b61e179773be4722bb81173dd599306/packages/theme/src/styles.ts#L13}
26+
*/
27+
const placeholderColor = useColorModeValue("gray.400", "whiteAlpha.400");
28+
2129
const initialStyles: SystemStyleObject = {
2230
color: placeholderColor,
2331
mx: "0.125rem",

src/module-augmentation.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,6 @@ declare module "react-select/dist/declarations/src/Select" {
139139
*/
140140
errorBorderColor?: string;
141141

142-
/**
143-
* The color used to style the text in the `Placeholder`, `LoadingMessage`,
144-
* and `NoOptionsMessage`.
145-
*
146-
* @defaultValue Light mode: `gray.400` | Dark mode: `whiteAlpha.400`
147-
* @see {@link https://github.com/chakra-ui/chakra-ui/blob/main/packages/theme/src/styles.ts#L13}
148-
*/
149-
placeholderColor?: string;
150-
151142
/**
152143
* Style transformation methods for each of the rendered components using,
153144
* Chakra's `SystemStyleObject` and the props passed into each component

src/use-chakra-select-props.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useFormControl } from "@chakra-ui/form-control";
2-
import { useColorModeValue } from "@chakra-ui/system";
32
import type { GroupBase, Props } from "react-select";
43
import chakraComponents from "./chakra-components";
54
import type { SelectedOptionStyle, Size, TagVariant } from "./types";
@@ -44,13 +43,6 @@ const useChakraSelectProps = <
4443
onBlur,
4544
});
4645

47-
/**
48-
* The chakra UI global placeholder color
49-
*
50-
* @see {@link https://github.com/chakra-ui/chakra-ui/blob/13c6d2e08b61e179773be4722bb81173dd599306/packages/theme/src/styles.ts#L13}
51-
*/
52-
const placeholderColor = useColorModeValue("gray.400", "whiteAlpha.400");
53-
5446
/** Ensure that the size used is one of the options, either `sm`, `md`, or `lg` */
5547
let realSize: Size = size;
5648
const sizeOptions: Size[] = ["sm", "md", "lg"];
@@ -96,7 +88,6 @@ const useChakraSelectProps = <
9688
selectedOptionStyle: realSelectedOptionStyle,
9789
selectedOptionColor: realSelectedOptionColor,
9890
hasStickyGroupHeaders,
99-
placeholderColor,
10091
chakraStyles,
10192
focusBorderColor,
10293
errorBorderColor,

0 commit comments

Comments
 (0)