-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [Mission1] feat: TextField UI 구현 * [Mission1] feat: useInput, useInputs 구현 * [Mission1] refactor: TextField css 수정, 불필요 코드 제거 #1
- Loading branch information
1 parent
e4391ca
commit ae29bf4
Showing
6 changed files
with
192 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,113 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import styled, { css } from 'styled-components'; | ||
|
||
const TextField = () => ( | ||
interface TextFieldProps { | ||
id?: string; | ||
name?: string; | ||
label?: string; | ||
placeholder?: string; | ||
error?: boolean; | ||
errorMessage?: string; | ||
readOnly?: boolean; | ||
disabled?: boolean; | ||
onChange?: (e: any) => void; | ||
|
||
[k: string]: any; | ||
} | ||
|
||
const TextField = ({ | ||
id, | ||
name, | ||
label, | ||
placeholder, | ||
error, | ||
errorMessage, | ||
readOnly, | ||
disabled, | ||
onChange, | ||
...props | ||
}: TextFieldProps) => ( | ||
<Container> | ||
TextField | ||
<Label htmlFor={id}>{label}</Label> | ||
<Input | ||
id={id} | ||
name={name} | ||
placeholder={placeholder} | ||
readOnly={readOnly} | ||
disabled={disabled} | ||
error={error} | ||
onChange={onChange} | ||
{...props} | ||
/> | ||
{ | ||
error && ( | ||
<ErrorMessage>{errorMessage}</ErrorMessage> | ||
) | ||
} | ||
</Container> | ||
); | ||
|
||
export default TextField; | ||
|
||
const Container = styled.div` | ||
width: 500px; | ||
height: auto; | ||
padding: 0 0 0 40px; | ||
display: flex; | ||
flex-direction: column; | ||
& + & { | ||
margin-top: 32px; | ||
} | ||
`; | ||
|
||
const Label = styled.label` | ||
width: 400px; | ||
height: 20px; | ||
border-radius: 4px; | ||
margin-bottom: 10px; | ||
`; | ||
|
||
const Input = styled.input<TextFieldProps>` | ||
width: 400px; | ||
height: 48px; | ||
border: 1px solid #E0E0E0; | ||
border-radius: 4px; | ||
padding: 0 16px; | ||
font-size: 14px; | ||
${(props) => props.error | ||
&& css` | ||
color: #EB5757 !important; | ||
border: 1px solid #EB5757 !important; | ||
`}; | ||
&::placeholder { | ||
color: #BDBDBD; | ||
} | ||
&:hover { | ||
border: 1px solid #828282; | ||
} | ||
&:focus { | ||
border: 1px solid #333333; | ||
outline: none; | ||
} | ||
&:read-only { | ||
color: #4F4F4F; | ||
border: 1px solid #E0E0E0; | ||
} | ||
&:disabled { | ||
color: #BDBDBD; | ||
border: 1px solid #E0E0E0; | ||
} | ||
`; | ||
|
||
const ErrorMessage = styled.div` | ||
color: #EB5757; | ||
font-size: 14px; | ||
margin-top: 8px; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters