Skip to content

Commit 092c0a4

Browse files
author
amars29
committed
fix: input shift on focus
1 parent d8e5bf2 commit 092c0a4

File tree

3 files changed

+77
-16
lines changed

3 files changed

+77
-16
lines changed

src/components/primitives/Input/Input.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,12 @@ const Input = (
112112
}
113113

114114
return (
115-
<Stack {..._stack} {...layoutProps} ref={mergeRefs([_ref, wrapperRef])}>
115+
<Stack
116+
{..._stack}
117+
{...layoutProps}
118+
ref={mergeRefs([_ref, wrapperRef])}
119+
isFocused={isFocused}
120+
>
116121
{InputLeftElement || leftElement ? InputLeftElement || leftElement : null}
117122
<StyledInput
118123
{...inputProps}

src/components/primitives/Stack/Stack.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,26 @@ export interface InterfaceStackProps extends InterfaceBoxProps<IStackProps> {
2828
direction?: ResponsiveValue<
2929
'column' | 'row' | 'column-reverse' | 'row-reverse'
3030
>;
31+
/**
32+
* If true, the Stack will be in hovered state.
33+
*/
34+
isHovered?: boolean;
35+
/**
36+
* If true, the Stack will be focused.
37+
*/
38+
isFocused?: boolean;
39+
/**
40+
* If true, the Stack will be disabled.
41+
*/
42+
isDisabled?: boolean;
43+
/**
44+
* If true, the Stack will be invalid.
45+
*/
46+
isInvalid?: boolean;
47+
/**
48+
* If true, prevents the value of the children from being edited. Used with FormControls.
49+
*/
50+
isReadOnly?: boolean;
3151
}
3252

3353
export type IStackProps = InterfaceStackProps | CustomProps<'Stack'>;
@@ -44,7 +64,13 @@ const Stack = ({ space, ...props }: IStackProps, ref?: any) => {
4464
}: any = usePropsResolution(
4565
'Stack',
4666
{ ...props, size: space },
47-
{},
67+
{
68+
isDisabled: props.isDisabled,
69+
isHovered: props.isHovered,
70+
isFocused: props.isFocused,
71+
isInvalid: props.isInvalid,
72+
isReadOnly: props.isReadOnly,
73+
},
4874
{ resolveResponsively: ['space', 'direction'] }
4975
);
5076

src/theme/components/input.ts

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,7 @@ const baseStyle = () => {
3737
style: { outline: 'none' },
3838
cursor: 'auto',
3939
},
40-
_stack: {
41-
flexDirection: 'row',
42-
alignItems: 'center',
43-
// justifyContent: 'space-between',
44-
overflow: 'hidden',
45-
},
40+
4641
_input: {
4742
bg: 'transparent',
4843
flex: 1,
@@ -72,6 +67,19 @@ const baseStyle = () => {
7267
borderColor: 'muted.300',
7368
},
7469
},
70+
_stack: {
71+
flexDirection: 'row',
72+
alignItems: 'center',
73+
// justifyContent: 'space-between',
74+
overflow: 'hidden',
75+
_focus: {
76+
style: {
77+
outlineWidth: '1px',
78+
outlineColor: 'primary.600',
79+
outlineStyle: 'solid',
80+
},
81+
},
82+
},
7583
},
7684
_dark: {
7785
placeholderTextColor: 'text.600',
@@ -98,6 +106,19 @@ const baseStyle = () => {
98106
borderColor: 'muted.700',
99107
},
100108
},
109+
_stack: {
110+
flexDirection: 'row',
111+
alignItems: 'center',
112+
// justifyContent: 'space-between',
113+
overflow: 'hidden',
114+
_focus: {
115+
style: {
116+
outlineWidth: '3px',
117+
outlineColor: 'primary.500',
118+
outlineStyle: 'solid',
119+
},
120+
},
121+
},
101122
},
102123
};
103124
};
@@ -108,7 +129,6 @@ function roundedStyle(props: Record<string, any>) {
108129
borderRadius: 'full',
109130
borderWidth: '1',
110131
_focus: {
111-
borderWidth: '2',
112132
bg: transparentize('primary.600', 0.1)(theme),
113133
},
114134
_invalid: {
@@ -121,7 +141,6 @@ function outlineStyle(props: Record<string, any>) {
121141
return {
122142
borderWidth: '1',
123143
_focus: {
124-
borderWidth: '2',
125144
bg: transparentize('primary.600', 0.1)(theme),
126145
},
127146
_invalid: {
@@ -132,10 +151,8 @@ function outlineStyle(props: Record<string, any>) {
132151
function filledStyle(props: Record<string, any>) {
133152
const { theme } = props;
134153
return {
135-
borderWidth: '0',
136-
borderColor: 'transparent',
154+
borderWidth: '1',
137155
_focus: {
138-
borderWidth: '2',
139156
bg: transparentize('primary.600', 0.1)(theme),
140157
},
141158
_hover: {
@@ -149,9 +166,11 @@ function filledStyle(props: Record<string, any>) {
149166
},
150167
_light: {
151168
bg: 'muted.100',
169+
borderColor: 'muted.100',
152170
},
153171
_dark: {
154172
bg: 'muted.800',
173+
borderColor: 'muted.800',
155174
},
156175
};
157176
}
@@ -167,16 +186,27 @@ function unstyledStyle() {
167186
_focus: {
168187
bg: 'transparent',
169188
},
189+
_stack: {
190+
_focus: {
191+
style: {
192+
outlineWidth: '0',
193+
},
194+
},
195+
},
170196
};
171197
}
172198
function underlinedStyle() {
173199
return {
174200
borderWidth: '0',
175201
pl: '0',
176202
borderBottomWidth: '1',
177-
_focus: {
178-
borderBottomWidth: '2',
179-
fontWeight: '500',
203+
_stack: {
204+
_focus: {
205+
style: {
206+
outlineWidth: '0',
207+
boxShadow: '0 1px 0 0 #0891B2',
208+
},
209+
},
180210
},
181211
_invalid: {
182212
borderBottomWidth: '2',

0 commit comments

Comments
 (0)