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

[조규진] Sprint8 #260

Conversation

gjrefa9139
Copy link
Collaborator

요구사항

Github에 PR(Pull Request)을 만들어서 미션을 제출합니다.
피그마 디자인에 맞게 페이지를 만들어 주세요.
Typescript를 사용합니다.

기본

  • 스프린트 미션 1 ~ 7에 대해 typescript를 적용해주세요.

주요 변경사항

스크린샷

멘토에게

  • 셀프 코드 리뷰를 통해 질문 이어가겠습니다.

@gjrefa9139 gjrefa9139 changed the base branch from main to React-조규진 August 3, 2024 02:54
@gjrefa9139 gjrefa9139 added the 미완성🫠 죄송합니다.. label Aug 3, 2024
Comment on lines +4 to +14
function InputItem(props: {
id: string;
label: string;
value: string;
placeholder: string;
isTextArea?: boolean;
onChange: (event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;
}) {
const { id, label, value, placeholder, isTextArea, onChange, onKeyDown } = props;

Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. props 타입을 별도로 정의하면 재사용성과 가독성이 향상될 수 있습니다.
  2. onKeyDown 이벤트는 텍스트 영역에서도 발생할 수 있으므로, 이에 대한 값도 필요합니다.
type InputItemProps = {
  id: string;
  label: string;
  value: string;
  placeholder?: string;
  isTextArea?: boolean;
  onChange: (event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
  onKeyDown?: (event: KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
};

function InputItem({
  id,
  label,
  value,
  placeholder = '',
  isTextArea = false,
  onChange,
  onKeyDown
}: InputItemProps) {

Copy link
Collaborator

Choose a reason for hiding this comment

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

여기서 KeyboardEvent 타입은 내부적으로 아래와 같은 타입을 갖고 있을거예요.

interface KeyboardEvent<T = Element> extends UIEvent {
  readonly altKey: boolean;
  readonly ctrlKey: boolean;
  readonly key: string;
  readonly keyCode: number;
  readonly metaKey: boolean;
  readonly shiftKey: boolean;
  readonly type: string;
  isComposing: boolean;
  getModifierState(key: string): boolean;
  // ... 기타 메서드와 속성들
}

그래서 제너릭 값으로 HTMLInputElement 혹은 HTMLTextAreaElement 값을 주게되면 아래처럼 변경된답니다.

interface KeyboardEvent<T = <HTMLInputElement | HTMLTextAreaElement>> extends UIEvent {

Comment on lines +5 to +13
interface RemoveIconProps {
className?: string;
label: string;
onClick: MouseEventHandler<SVGSVGElement>;
}

function RemoveIcon({ className, label, onClick }: RemoveIconProps) {
return <XIcon className={`deleteIcon ${className}`} aria-label={`${label} 삭제`} onClick={onClick} />;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

굳 입니다! 👍

Comment on lines +4 to +7
interface DropdownMenuProps {
onSortSelection: (sortOption: ProductSortOption) => void;
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

여기서 ProductSortOption 값을 별도로 import 하는 방법 좋아요.
sortOption 값은 여기말고도 다양하게 사용될 수 있는 값 이거든요. 보통 이런 타입들은 export 해서 외부에서 사용가능하도록 합니다.

isFavorite: boolean;
}

export type ProductSortOption = 'recent' | 'favorite';
Copy link
Collaborator

Choose a reason for hiding this comment

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

굳! 위처럼 별도로 정의 후 사용하게 되면 해당 타입을 다른 곳에서 재사용 할 수 있겠죠?

Comment on lines 14 to 21

/* Language and Environment */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
"target": "ESNext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"lib": ["dom", "dom.iterable", "esnext"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
"jsx": "react-jsx", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
Copy link
Collaborator

Choose a reason for hiding this comment

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

tsconfig 설정 잘하셨습니다.
각각 어떤 의미가 있는지 공부해보면 좋겠어요. 🙂
컴파일 대상 파일들을 어떻게 변환할지 다양한 옵션들이 많거든요.

https://www.typescriptlang.org/tsconfig/

Comment on lines +1 to +22
// const login = document.getElementById('login');
// const signup = document.getElementById('signup');
// const email = document.getElementById('email');
// const nickname = document.getElementById('nickname');
// const password = document.getElementById('password');
// const passwordConfirmationInput = document.getElementById('passwordConfirmation');
// const submitButton = document.querySelector('.auth-container form button[type="submit"]');

// function showError(input, errorId) {
// const errorElement = document.getElementById(errorId);
// errorElement.style.display = 'block';
// input.style.border = '1px solid #f74747';
// }

// function hideError(input, errorId) {
// const errorElement = document.getElementById(errorId);
// errorElement.style.display = 'none';
// input.style.border = 'none';
// }

// function validateEmailString(email) {
// const emailRegex = /^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/;
Copy link
Collaborator

Choose a reason for hiding this comment

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

요건 파일 자체를 제거해주셔도 좋겠네요.

Copy link
Collaborator

@arthurkimdev arthurkimdev left a comment

Choose a reason for hiding this comment

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

규진님 과제 제출하시느라 수고 많으셨습니다~ 🙏

@arthurkimdev arthurkimdev merged commit 4f93c18 into codeit-bootcamp-frontend:React-조규진 Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
미완성🫠 죄송합니다..
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants