-
Notifications
You must be signed in to change notification settings - Fork 39
[이태경] Sprint8 #236
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
The head ref may contain hidden characters: "React-\uC774\uD0DC\uACBD-sprint8"
[이태경] Sprint8 #236
Changes from 57 commits
264f1bf
5f955f8
e694c31
5b86550
5b97985
ba727b2
5b034ad
f14a68d
2c2c551
82b3daf
9f9206b
0f182f1
e8b8868
1702a3c
897ddae
b7afd87
a64c63b
7e6e100
a445ac7
8de8d2b
92d4853
be1e40e
bba7c38
3ae3659
bd2054a
831e6ae
c89d9f3
1697909
3bb9472
038478b
e240602
427e5af
7855ca4
a1cf6fd
635075f
271cf29
0888dc8
f44d420
305d791
db43963
40d3594
606158d
c6d93bf
656f8f2
a590c4e
b021426
3670b38
40b8986
4e4dac8
650ae17
8076d76
30fa5f1
a5e7e94
38243a2
4ba7e9f
51b3c10
72fdfac
5c2d72e
286bbee
60bb560
91f5869
7401167
e277b12
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import PasswordInput from "../PasswordInput/PasswordInput"; | ||
| import Input from "../Input/Input"; | ||
| import { forwardRef, InputHTMLAttributes } from "react"; | ||
|
|
||
| interface Props extends InputHTMLAttributes<HTMLInputElement> { | ||
| label: string; | ||
| errorMsg?: string; | ||
| } | ||
|
|
||
| const AuthFormInput = forwardRef<HTMLInputElement, Props>( | ||
| ({ label, errorMsg, ...props }, ref) => { | ||
| return ( | ||
| <div className="auth-form__item"> | ||
| <label className="auth-form__label">{label}</label> | ||
| {props.type === "password" ? ( | ||
| <PasswordInput ref={ref} {...props} /> | ||
| ) : ( | ||
| <Input ref={ref} {...props} /> | ||
| )} | ||
| {errorMsg && <p className="auth-form__error-msg">{errorMsg}</p>} | ||
| </div> | ||
| ); | ||
| } | ||
| ); | ||
| export default AuthFormInput; |
This file was deleted.
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. module CSS와 css-in-js를 혼용해서 쓰고계시네요! 각 방식중 하나로 통일하는걸 추천드립니다! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { forwardRef, InputHTMLAttributes } from "react"; | ||
| import styles from "./Input.module.scss"; | ||
|
|
||
| interface Props extends InputHTMLAttributes<HTMLInputElement> {} | ||
|
|
||
| const Input = forwardRef<HTMLInputElement, Props>( | ||
| ({ className, ...props }, ref) => { | ||
| return ( | ||
| <input ref={ref} className={`${styles.input} ${className}`} {...props} /> | ||
| ); | ||
| } | ||
| ); | ||
|
|
||
| export default Input; |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import { forwardRef, InputHTMLAttributes } from "react"; | ||
| import usePasswordToggle from "../../hooks/usePasswordToggle"; | ||
| import styles from "./PasswordInput.module.scss"; | ||
|
|
||
| interface Props extends InputHTMLAttributes<HTMLInputElement> { | ||
| placeholder?: string; | ||
| className?: string; | ||
| isToggle?: boolean; | ||
| } | ||
|
|
||
| const PasswordInput = forwardRef<HTMLInputElement, Props>( | ||
| ({ placeholder, className, isToggle = true, ...props }, ref) => { | ||
| const { toggle, handleClickToggle, toggleImg } = usePasswordToggle(); | ||
|
|
||
| const { type, ...otherProps } = props; | ||
|
||
|
|
||
| return ( | ||
| <div className={styles["password-box"]}> | ||
| <input | ||
| ref={ref} | ||
| type={toggle ? "text" : "password"} | ||
| placeholder={placeholder} | ||
| className={`${styles["password-input"]} ${className}`} | ||
| {...otherProps} | ||
| /> | ||
| {isToggle && ( | ||
| <button | ||
| type="button" | ||
| className={styles["password__toggle-btn"]} | ||
| aria-label="비밀번호 표시" | ||
| aria-pressed={toggle} | ||
| onClick={handleClickToggle} | ||
| > | ||
| <img | ||
| src={toggleImg} | ||
| width="24" | ||
| height="24" | ||
| alt="비밀번호 보기 아이콘" | ||
| /> | ||
| </button> | ||
| )} | ||
| </div> | ||
| ); | ||
| } | ||
| ); | ||
|
|
||
| export default PasswordInput; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,15 +8,20 @@ interface TagItemBase { | |
| children: ReactNode; | ||
| } | ||
|
|
||
| type TextProps = HTMLAttributes<HTMLSpanElement> & | ||
| TagItemBase & { | ||
| type: "text"; | ||
| }; | ||
| type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & | ||
| TagItemBase & { | ||
| type: "button"; | ||
| onClick: () => void; | ||
| }; | ||
| interface TextProps | ||
| extends Omit<HTMLAttributes<HTMLSpanElement>, "children">, | ||
| TagItemBase { | ||
| type: "text"; | ||
| } | ||
|
||
| interface ButtonProps | ||
| extends Omit< | ||
| ButtonHTMLAttributes<HTMLButtonElement>, | ||
| "onClick" | "type" | "children" | ||
| >, | ||
| TagItemBase { | ||
| type: "button"; | ||
| onClick: () => void; | ||
| } | ||
|
|
||
| type TagItemProps = TextProps | ButtonProps; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
구문을 이렇게 간소화해볼수있을것같아요.
color 속성은 지금 코드베이스를 파악해보면 CSS-in-js에서 나중에 variant 기반으로 처리되게끔 만들어져있어 제외될 필요가 없고, (일반적으로 props를 받아서 인라인으로 적용해주는 경우는 많이 없을테니까) children 속성은 interface의 확장 시 선언 병합이 되는 특징때문에 동일 속성명을 나중에 선언하게되면 이전 타입을 오버라이드하기때문에 일부러 제거해주지않아도 괜찮아요 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아! 아 이것도 질문을 남겼어야했는데ㅠㅠ 깜빡했네요
예시로 주신 코드로 적용을 하니깐, 제 코드에서는 계속 에러를 뿜더라구요.
ButtonHTMLAttributes에 존재하는 children을 ButtonProps에서 다시 옵셔널한 타입으로 재정의 해줘서 발생한 오류 같아서 Omit으로 제거해주니깐 해결이 되었었어요!
혹시 제가 놓친게 있을까요?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다시 해보니깐... 오류가 안나네요.... 타입에러가 계속 떴었는데 이상하네요;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ㅎㅎ 분명 코드상으로는 잘못한게 없는데도 타입 에러가 계속 남아있으면 restart ts server 커맨드 사용해서 서버 재시작 해보세요! 가끔 서버가 재시작되어야 타입 체크가 제대로 되는 경우도 있답니다 😌