Skip to content

Commit 944f0a5

Browse files
committed
fix: colorScheme and colorValue for Input
1 parent 5df5039 commit 944f0a5

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

apps/docs/pages/docs/Components/Inputs/input.en-US.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,14 @@ Extends every `Box` props and react native `TextInput` component.
8989

9090
https://reactnative.dev/docs/textinput#props
9191

92+
### `colorScheme`
93+
<PropsTable
94+
description="The colorScheme property, will define the focus border main color."
95+
prop={{ type: "string", required: false }}
96+
/>
97+
98+
### `colorValue`
99+
<PropsTable
100+
description="The colorValue property, will define the focus border color tint."
101+
prop={{ type: "number", required: false }}
102+
/>

packages/react-native-ficus-ui/src/components/input/index.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ export interface InputProps
3232
PrefixSuffixProps,
3333
Omit<TextProps, 'textAlign' | 'textAlignVertical' | 'as'>,
3434
InputOptions,
35-
ThemingProps<'Input'> {}
35+
ThemingProps<'Input'> {
36+
colorValue?: number;
37+
}
3638

3739
export const Input = forwardRef<InputProps, 'TextInput'>((props, ref) => {
3840
const [isFocused, setIsFocused] = useState(false);
@@ -104,16 +106,20 @@ export const Input = forwardRef<InputProps, 'TextInput'>((props, ref) => {
104106
innerRef?.current?.focus();
105107
}
106108
};
109+
const scheme = props.colorScheme ?? inputContainerStyles.colorScheme;
107110

108-
const colorValue = useColorModeValue(500, 300);
111+
const defaultColorValue = useColorModeValue(500, 300);
112+
113+
const colorValue =
114+
props.colorValue ?? inputContainerStyles.colorValue ?? defaultColorValue;
109115

110116
return (
111117
<ficus.TouchableWithoutFeedback onPress={onPressComponent}>
112118
<ficus.View
113119
__styles={inputContainerStyles}
114-
{...(isFocused && props.colorScheme
120+
{...(isFocused && scheme
115121
? {
116-
borderColor: `${props.colorScheme}.${colorValue}`,
122+
borderColor: `${scheme}.${colorValue}`,
117123
}
118124
: {})}
119125
>

0 commit comments

Comments
 (0)