-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ISSUE-45] feat: 아이디, 비밀번호 Input 컴포넌트 생성 (#31)
- Loading branch information
1 parent
31a9be1
commit fab2e56
Showing
2 changed files
with
154 additions
and
70 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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
'use client'; | ||
|
||
import { FaLock, FaUserAlt } from 'react-icons/fa'; | ||
import styled from 'styled-components'; | ||
|
||
import { COLORS, TEXT_COLORS } from '../../constants/colors'; | ||
import { FONTS } from '../../constants/font'; | ||
|
||
const CustomInput = ({ | ||
name, | ||
value, | ||
type = 'text', | ||
placeholder = '', | ||
onChange, | ||
passwordVisible, | ||
togglePasswordVisibility, | ||
}) => { | ||
return ( | ||
<InputWrapper> | ||
<IconWrapper>{type === 'id' ? <FaUserAlt /> : <FaLock />}</IconWrapper> | ||
<StyledInput | ||
type={type === 'password' && !passwordVisible ? 'password' : 'text'} | ||
name={name} | ||
value={value} | ||
placeholder={placeholder} | ||
onChange={onChange} | ||
/> | ||
{type === 'password' && ( | ||
<ShowButton onClick={togglePasswordVisibility}>{passwordVisible ? 'Hide' : 'Show'}</ShowButton> | ||
)} | ||
</InputWrapper> | ||
); | ||
}; | ||
|
||
export default CustomInput; | ||
|
||
const InputWrapper = styled.div` | ||
width: 100%; | ||
height: 3rem; | ||
display: flex; | ||
align-items: center; | ||
background-color: ${COLORS.softMint}; | ||
border-radius: 0.5rem; | ||
padding: 0.75rem; | ||
position: relative; | ||
`; | ||
|
||
const StyledInput = styled.input` | ||
flex-grow: 1; | ||
background-color: ${COLORS.softMint}; | ||
border: none; | ||
font-family: ${FONTS.PRETENDARD[400]}; | ||
font-size: 1rem; | ||
color: ${TEXT_COLORS.default}; | ||
&::placeholder { | ||
color: ${TEXT_COLORS.placeholder}; | ||
} | ||
&:focus { | ||
outline: none; | ||
border: none; | ||
} | ||
`; | ||
|
||
const IconWrapper = styled.div` | ||
padding-right: 0.5rem; | ||
color: ${COLORS.primary}; | ||
`; | ||
|
||
const ShowButton = styled.button` | ||
background: none; | ||
border: none; | ||
color: ${COLORS.primary}; | ||
cursor: pointer; | ||
padding: 0 0.5rem; | ||
font-size: 0.875rem; | ||
position: absolute; | ||
right: 10px; | ||
&:focus { | ||
outline: none; | ||
} | ||
`; |