Skip to content

Commit

Permalink
refactor/BibimMandu-IssueTacker#67: 입력 컴포넌트에 패스워드 타입 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
qkdflrgs committed Aug 4, 2023
1 parent bbbdb1b commit 61c54e1
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions FE/src/components/common/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,42 @@ import { styled } from "styled-components";

type Props = {
id?: string;
inputType?: "text" | "password";
placeholder?: string;
handleFocus?(): void;
handleBlur?(): void;
updateInputValue?(value: string): void;
onChange?(e: React.ChangeEvent<HTMLInputElement>): void;
value?: string;
handleEnterFilter?(): void;
};

export default function Input({
id,
inputType = "text",
placeholder,
handleFocus,
handleBlur,
updateInputValue,
onChange,
value,
handleEnterFilter,
}: Props) {
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
updateInputValue!(e.target.value);
const enterKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (e.key === "Enter") {
e.preventDefault();
handleEnterFilter && handleEnterFilter();
}
};

return (
<TextInput
id={id}
type="text"
type={inputType}
placeholder={placeholder}
onChange={handleInputChange}
onChange={onChange}
onFocus={handleFocus}
onBlur={handleBlur}
value={value}
onKeyPress={enterKeyPress}
/>
);
}
Expand Down

0 comments on commit 61c54e1

Please sign in to comment.