Skip to content

Commit c56d1bf

Browse files
committed
feat: added prop for invalid outline color
1 parent a08cc51 commit c56d1bf

File tree

3 files changed

+85
-18
lines changed

3 files changed

+85
-18
lines changed

src/components/primitives/Input/Input.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ const Input = (
3939
/**Converting into Hash Color Code */
4040
//@ts-ignore
4141
props.focusOutlineColor = useToken('colors', props.focusOutlineColor);
42+
//@ts-ignore
43+
props.inValidOutlineColor = useToken('colors', props.inValidOutlineColor);
4244

4345
const _ref = React.useRef(null);
4446
const { isHovered } = useHover({}, _ref);

src/components/primitives/Input/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ export interface InterfaceInputProps
108108
_stack?: Partial<IStackProps>;
109109
/** This prop allow you to change outlineColor when input is in focused state*/
110110
focusOutlineColor?: ColorType;
111+
/** This prop allow you to change outlineColor when input is in focused state*/
112+
inValidOutlineColor?: ColorType;
111113
}
112114

113115
export interface IInputGroupProps extends InterfaceBoxProps<IInputGroupProps> {

src/theme/components/input.ts

Lines changed: 81 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { transparentize } from '../tools';
22
const baseStyle = (props: any) => {
3-
const { primary } = props.theme.colors;
3+
const { primary, error } = props.theme.colors;
44

55
return {
66
fontFamily: 'body',
@@ -47,6 +47,24 @@ const baseStyle = (props: any) => {
4747
},
4848
_invalid: {
4949
borderColor: 'error.600',
50+
_hover: { borderColor: 'error.600' },
51+
_focus: {
52+
borderColor: 'error.600',
53+
_stack: {
54+
style: {
55+
outlineWidth: '1px',
56+
outlineColor: `${props.inValidOutlineColor || error[600]}`,
57+
outlineStyle: 'solid',
58+
},
59+
},
60+
},
61+
_stack: {
62+
style: {
63+
outlineWidth: '1px',
64+
outlineColor: `${props.inValidOutlineColor || error[600]}`,
65+
outlineStyle: 'solid',
66+
},
67+
},
5068
},
5169
_ios: {
5270
selectionColor: 'coolGray.800',
@@ -86,6 +104,24 @@ const baseStyle = (props: any) => {
86104
},
87105
_invalid: {
88106
borderColor: 'error.500',
107+
_stack: {
108+
style: {
109+
outlineWidth: '1px',
110+
outlineColor: `${props.inValidOutlineColor || error[500]}`,
111+
outlineStyle: 'solid',
112+
},
113+
},
114+
_hover: { borderColor: 'error.500' },
115+
_focus: {
116+
borderColor: 'error.500',
117+
_stack: {
118+
style: {
119+
outlineWidth: '1px',
120+
outlineColor: `${props.inValidOutlineColor || error[500]}`,
121+
outlineStyle: 'solid',
122+
},
123+
},
124+
},
89125
},
90126
_ios: {
91127
selectionColor: 'warmGray.50',
@@ -117,9 +153,6 @@ function roundedStyle(props: Record<string, any>) {
117153
_focus: {
118154
bg: transparentize('primary.600', 0.1)(theme),
119155
},
120-
_invalid: {
121-
borderWidth: '2',
122-
},
123156
};
124157
}
125158
function outlineStyle(props: Record<string, any>) {
@@ -129,9 +162,6 @@ function outlineStyle(props: Record<string, any>) {
129162
_focus: {
130163
bg: transparentize('primary.600', 0.1)(theme),
131164
},
132-
_invalid: {
133-
borderWidth: '2',
134-
},
135165
};
136166
}
137167
function filledStyle(props: Record<string, any>) {
@@ -147,9 +177,6 @@ function filledStyle(props: Record<string, any>) {
147177
borderWidth: 0,
148178
},
149179
},
150-
_invalid: {
151-
borderWidth: '2',
152-
},
153180
_light: {
154181
bg: 'muted.100',
155182
borderColor: 'muted.100',
@@ -172,6 +199,13 @@ function unstyledStyle() {
172199
_focus: {
173200
bg: 'transparent',
174201
},
202+
_invalid: {
203+
_stack: {
204+
style: {
205+
outlineWidth: 0,
206+
},
207+
},
208+
},
175209
_stack: {
176210
_focus: {
177211
style: {
@@ -182,35 +216,64 @@ function unstyledStyle() {
182216
};
183217
}
184218
function underlinedStyle(props: Record<string, any>) {
185-
const { primary } = props.theme.colors;
219+
const { primary, error } = props.theme.colors;
186220

187221
return {
188222
borderWidth: '0',
189223
pl: '0',
190224
borderBottomWidth: '1',
191225
_light: {
192-
_stack: {
193-
_focus: {
226+
_focus: {
227+
_stack: {
194228
style: {
195229
outlineWidth: '0',
196230
boxShadow: `0 1px 0 0 ${props.focusOutlineColor || primary[600]}`,
197231
},
198232
},
233+
_invalid: {
234+
_stack: {
235+
style: {
236+
boxShadow: `0 1px 0 0 ${props.inValidOutlineColor || error[600]}`,
237+
},
238+
},
239+
},
240+
},
241+
_invalid: {
242+
_stack: {
243+
style: {
244+
outlineWidth: 0,
245+
boxShadow: `0 1px 0 0 ${props.inValidOutlineColor || error[600]}`,
246+
},
247+
},
199248
},
200249
},
201250
_dark: {
202-
_stack: {
203-
_focus: {
251+
_focus: {
252+
_stack: {
204253
style: {
205254
outlineWidth: '0',
206255
boxShadow: `0 1px 0 0 ${props.focusOutlineColor || primary[500]}`,
207256
},
208257
},
258+
_invalid: {
259+
_stack: {
260+
style: {
261+
outlineWidth: 0,
262+
boxShadow: `0 1px 0 0 ${props.inValidOutlineColor || error[500]}`,
263+
},
264+
},
265+
},
266+
},
267+
_invalid: {
268+
_stack: {
269+
style: {
270+
outlineWidth: 0,
271+
boxShadow: `0 1px 0 0 ${props.focusOutlineColor || error[500]}`,
272+
},
273+
},
209274
},
210275
},
211-
_invalid: {
212-
borderBottomWidth: '2',
213-
},
276+
214277
borderRadius: 0,
215278
};
216279
}

0 commit comments

Comments
 (0)