Skip to content

Commit e3e29b6

Browse files
authored
Merge pull request #4898 from GeekyAnts/feat/new-outlinecolor-props
Feat/new outlinecolor props
2 parents 99ceb5d + 0f4c972 commit e3e29b6

File tree

3 files changed

+88
-38
lines changed

3 files changed

+88
-38
lines changed

src/components/primitives/Input/Input.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ const Input = (
3636
callback();
3737
};
3838

39+
/**Converting into Hash Color Code */
40+
//@ts-ignore
41+
props.focusOutlineColor = useToken('colors', props.focusOutlineColor);
42+
//@ts-ignore
43+
props.inValidOutlineColor = useToken('colors', props.inValidOutlineColor);
44+
3945
const _ref = React.useRef(null);
4046
const { isHovered } = useHover({}, _ref);
4147

@@ -68,6 +74,7 @@ const Input = (
6874
wrapperRef,
6975
_stack,
7076
_input,
77+
7178
...resolvedProps
7279
} = usePropsResolution(
7380
'Input',

src/components/primitives/Input/types.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
VariantType,
77
} from '../../types';
88
import type { InterfaceBoxProps } from '../Box';
9-
import type { ResponsiveValue } from '../../../components/types';
9+
import type { ResponsiveValue, ColorType } from '../../../components/types';
1010
import type { ISizes } from '../../../theme/base/sizes';
1111
import type { CustomProps } from '../../types';
1212
import type { IStackProps } from '../Stack/Stack';
@@ -106,6 +106,10 @@ export interface InterfaceInputProps
106106
* Props to be passed to the Stack used inside.
107107
*/
108108
_stack?: Partial<IStackProps>;
109+
/** This prop allow you to change outlineColor when input is in focused state*/
110+
focusOutlineColor?: ColorType;
111+
/** This prop allow you to change outlineColor when input is in focused state*/
112+
inValidOutlineColor?: ColorType;
109113
}
110114

111115
export interface IInputGroupProps extends InterfaceBoxProps<IInputGroupProps> {

src/theme/components/input.ts

Lines changed: 76 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
1-
import { transparentize, mode } from '../tools';
2-
1+
import { transparentize } from '../tools';
32
const baseStyle = (props: any) => {
4-
const { primary } = props.theme.colors;
5-
const focusRing = mode(
6-
{
7-
outlineWidth: '1px',
8-
outlineColor: `${primary[600]}`,
9-
outlineStyle: 'solid',
10-
},
11-
{
12-
outlineWidth: '1px',
13-
outlineColor: `${primary[500]}`,
14-
outlineStyle: 'solid',
15-
}
16-
)(props);
3+
const { primary, error } = props.theme.colors;
4+
175
return {
186
fontFamily: 'body',
197
py: '2',
@@ -49,9 +37,25 @@ const baseStyle = (props: any) => {
4937
},
5038
_focus: {
5139
borderColor: 'primary.600',
40+
_hover: { borderColor: 'primary.600' },
41+
_stack: {
42+
style: {
43+
outlineWidth: '1px',
44+
outlineColor: `${props.focusOutlineColor || primary[600]}`,
45+
outlineStyle: 'solid',
46+
},
47+
},
5248
},
5349
_invalid: {
5450
borderColor: 'error.600',
51+
_hover: { borderColor: 'error.600' },
52+
_stack: {
53+
style: {
54+
outlineWidth: '1px',
55+
outlineColor: `${props.inValidOutlineColor || error[600]}`,
56+
outlineStyle: 'solid',
57+
},
58+
},
5559
},
5660
_ios: {
5761
selectionColor: 'coolGray.800',
@@ -70,9 +74,6 @@ const baseStyle = (props: any) => {
7074
alignItems: 'center',
7175
// justifyContent: 'space-between',
7276
overflow: 'hidden',
73-
_focus: {
74-
style: { ...focusRing },
75-
},
7677
},
7778
},
7879
_dark: {
@@ -84,9 +85,25 @@ const baseStyle = (props: any) => {
8485
},
8586
_focus: {
8687
borderColor: 'primary.500',
88+
_hover: { borderColor: 'primary.500' },
89+
_stack: {
90+
style: {
91+
outlineWidth: '1px',
92+
outlineColor: `${props.focusOutlineColor || primary[500]}`,
93+
outlineStyle: 'solid',
94+
},
95+
},
8796
},
8897
_invalid: {
8998
borderColor: 'error.500',
99+
_stack: {
100+
style: {
101+
outlineWidth: '1px',
102+
outlineColor: `${props.inValidOutlineColor || error[500]}`,
103+
outlineStyle: 'solid',
104+
},
105+
},
106+
_hover: { borderColor: 'error.500' },
90107
},
91108
_ios: {
92109
selectionColor: 'warmGray.50',
@@ -105,9 +122,6 @@ const baseStyle = (props: any) => {
105122
alignItems: 'center',
106123
// justifyContent: 'space-between',
107124
overflow: 'hidden',
108-
_focus: {
109-
style: { ...focusRing },
110-
},
111125
},
112126
},
113127
};
@@ -121,9 +135,6 @@ function roundedStyle(props: Record<string, any>) {
121135
_focus: {
122136
bg: transparentize('primary.600', 0.1)(theme),
123137
},
124-
_invalid: {
125-
borderWidth: '2',
126-
},
127138
};
128139
}
129140
function outlineStyle(props: Record<string, any>) {
@@ -133,9 +144,6 @@ function outlineStyle(props: Record<string, any>) {
133144
_focus: {
134145
bg: transparentize('primary.600', 0.1)(theme),
135146
},
136-
_invalid: {
137-
borderWidth: '2',
138-
},
139147
};
140148
}
141149
function filledStyle(props: Record<string, any>) {
@@ -151,9 +159,6 @@ function filledStyle(props: Record<string, any>) {
151159
borderWidth: 0,
152160
},
153161
},
154-
_invalid: {
155-
borderWidth: '2',
156-
},
157162
_light: {
158163
bg: 'muted.100',
159164
borderColor: 'muted.100',
@@ -176,6 +181,13 @@ function unstyledStyle() {
176181
_focus: {
177182
bg: 'transparent',
178183
},
184+
_invalid: {
185+
_stack: {
186+
style: {
187+
outlineWidth: 0,
188+
},
189+
},
190+
},
179191
_stack: {
180192
_focus: {
181193
style: {
@@ -185,21 +197,48 @@ function unstyledStyle() {
185197
},
186198
};
187199
}
188-
function underlinedStyle() {
200+
function underlinedStyle(props: Record<string, any>) {
201+
const { primary, error } = props.theme.colors;
202+
189203
return {
190204
borderWidth: '0',
191205
pl: '0',
192206
borderBottomWidth: '1',
193-
_stack: {
207+
_light: {
194208
_focus: {
195-
style: {
196-
outlineWidth: '0',
197-
boxShadow: '0 1px 0 0 #0891B2',
209+
_stack: {
210+
style: {
211+
outlineWidth: '0',
212+
boxShadow: `0 1px 0 0 ${props.focusOutlineColor || primary[600]}`,
213+
},
214+
},
215+
},
216+
_invalid: {
217+
_stack: {
218+
style: {
219+
outlineWidth: 0,
220+
boxShadow: `0 1px 0 0 ${props.inValidOutlineColor || error[600]}`,
221+
},
198222
},
199223
},
200224
},
201-
_invalid: {
202-
borderBottomWidth: '2',
225+
_dark: {
226+
_focus: {
227+
_stack: {
228+
style: {
229+
outlineWidth: '0',
230+
boxShadow: `0 1px 0 0 ${props.focusOutlineColor || primary[500]}`,
231+
},
232+
},
233+
},
234+
_invalid: {
235+
_stack: {
236+
style: {
237+
outlineWidth: 0,
238+
boxShadow: `0 1px 0 0 ${props.focusOutlineColor || error[500]}`,
239+
},
240+
},
241+
},
203242
},
204243
borderRadius: 0,
205244
};

0 commit comments

Comments
 (0)