Skip to content

Commit 9643df1

Browse files
committed
Refactor InputField to use styled components
1 parent 96b090c commit 9643df1

3 files changed

Lines changed: 22 additions & 18 deletions

File tree

src/components/InputField/InputField.scss

Whitespace-only changes.

src/components/InputField/InputField.tsx

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { ChangeEvent } from "react";
2-
import "./InputField.scss";
2+
3+
import { StyledContainer, StyledInput } from "./styles";
34

45
interface InputFieldProps<T> {
56
name: string;
@@ -30,28 +31,16 @@ function InputField<T>({
3031
}
3132

3233
return (
33-
<div
34-
className="input-field__container"
35-
style={{
36-
display: "flex",
37-
flexDirection: "column",
38-
justifyContent: "center",
39-
alignItems: "flex-start",
40-
width: "100%",
41-
gap: 10,
42-
}}
43-
>
44-
<span className="input-field__name">{name}</span>
45-
<input
46-
className="input-field__value"
34+
<StyledContainer>
35+
<span>{name}</span>
36+
<StyledInput
4737
type={getInputType()}
4838
defaultValue={defaultValue}
4939
onChange={handleChange}
50-
style={{ width: "100%", boxSizing: "border-box" }}
5140
autoFocus
52-
></input>
41+
/>
5342
{error && <span className="input-field__error">{error}</span>}
54-
</div>
43+
</StyledContainer>
5544
);
5645
}
5746

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import styled from "@emotion/styled";
2+
3+
export const StyledContainer = styled.div`
4+
display: flex;
5+
flex-direction: column;
6+
justify-content: center;
7+
align-items: flex-start;
8+
width: 100%;
9+
gap: 10;
10+
`;
11+
12+
export const StyledInput = styled.input`
13+
width: 100%;
14+
box-sizing: border-box;
15+
`;

0 commit comments

Comments
 (0)