Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REV-76/비밀번호 입력 컴포넌트 구현 #13

Merged
merged 5 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/assets/icons/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export { default as CloseIcon } from './close.svg?react'
export { default as PassWord } from './password.svg?react'
export { default as PassWordConfirm } from './passwordconfirm.svg?react'
4 changes: 4 additions & 0 deletions src/assets/icons/password.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/assets/icons/passwordconfirm.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions src/components/PasswordInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { ChangeEvent, ComponentPropsWithoutRef } from 'react'
import { PassWord, PassWordConfirm } from '@/assets/icons'

interface PasswordInputProps
extends Omit<ComponentPropsWithoutRef<'input'>, 'onChange'> {
type: 'password' | 'confirmation'
onChange?: (newPassword?: string) => void
disabled?: boolean
placeholder?: string
}

const PassWordInput = ({
type,
placeholder,
disabled,
onChange,
...rest // 나머지 프로퍼티를 수집
}: PasswordInputProps) => {
const handlePassWordChange = (event: ChangeEvent<HTMLInputElement>) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저희 팀 규칙으로 이벤트 객체 매개변수 명은 e로 명시하기로 정했습니다! ㅎㅎ

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아앗...감사합니다

onChange && onChange(event.target.value)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onChange 함수를 외부에서 받고 있는데, handlePassWordChange를 따로 구현할 필요가 있을까요??
prop으로 받는 onChange 함수 명을 handlePassWordChange로 바꾸고, 바로 적용시켜줘도 깔끔할 것 같습니다!


return (
<div className="items-center2 relative flex h-fit w-fit flex-row content-center justify-center gap-2 border-2 border-black">
<input
className="input border-0 bg-white pl-8 text-black"
placeholder={placeholder ?? '새 비밀번호 입력'}
disabled={disabled}
onChange={handlePassWordChange}
{...rest} // 나머지 프로퍼티를 전달
/>
<i className="flex items-center">
{type === 'password' ? <PassWord /> : <PassWordConfirm />}
</i>
</div>
)
}

export default PassWordInput
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as PassWordInput } from './PasswordInput'
Loading