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

feat : checkboxGroup 추가 #115

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

feat : checkboxGroup 추가 #115

wants to merge 5 commits into from

Conversation

GulSam00
Copy link
Member

@GulSam00 GulSam00 commented Jul 2, 2023

바뀐점

checkboxGroup 컴포넌트 추가

바꾼이유

설명

RadioGroup 참고하여 작업.

RadioGroup 처럼 selectedValue string 배열을 Context로 만들어서 전달. Checkbox 내부에서 대조하여서 적용.

@github-actions
Copy link

github-actions bot commented Jul 2, 2023

Alpha-115 - 2238020

check the deploy status here

Check it out!

Or you can try...

yarn add @rookies-team/design@https://pages.rookies.kr/design/0.26.0-alpha115-2238020/rookies-team-design-v0.26.0-alpha115-2238020.tgz

import type { Meta, StoryObj } from '@storybook/react';
import { CheckboxGroup } from './CheckboxGroup';
import { Checkbox } from './Checkbox';
import { Children } from 'react';
Copy link
Contributor

@asdf99245 asdf99245 Jul 2, 2023

Choose a reason for hiding this comment

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

import {Children} 요거땜에 build안되는거같네여 지우면될거같아여

@asdf99245
Copy link
Contributor

흠 뭐지 prettier에서 오류가 엄청 나네요 로컬에서 yarn format:fix 한번 하고 올려보시져

@Skyrich2000
Copy link
Member

앗 혹시 윈도우이슈..?

@raejun92
Copy link
Member

raejun92 commented Jul 2, 2023

윈도우는 컴퓨턴가요?

Copy link
Member

@Seojunhwan Seojunhwan left a comment

Choose a reason for hiding this comment

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

@asdf99245 @GulSam00 리뷰 남겼어요!!!!!

유틸함수 추가했는데, 추후에 페어로 요거 리팩토링 어떠신지?,,

Comment on lines +9 to +11
type CheckboxContextType = Omit<Props, 'children'>;

export const CheckboxContext = createContext<CheckboxContextType | null>(null);
Copy link
Member

Choose a reason for hiding this comment

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

@asdf99245, @GulSam00
context는 context.ts파일로 분리하는 것은 어떨까요?

Copy link
Contributor

Choose a reason for hiding this comment

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

좋네요 👍

Copy link
Member

Choose a reason for hiding this comment

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

좋습니다

Copy link
Member Author

Choose a reason for hiding this comment

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

요거는 utils의 createContext 이용해서 분리하게 되는거죠? 일단은 냅둘게요...!

Comment on lines +21 to +24
if (context) {
checked = context.selectedValue.includes(value);
onChange = context.onChange;
}
Copy link
Member

Choose a reason for hiding this comment

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

onChangeFromProps와 onChangeFromContext 모두 event를 전달하여 동작하게끔 하는 건 어떨까요?

요게 이유가 Checkbox에 핸들러를 전달했는데, context에 핸들러가 있을 경우 무시하게 되는데, 개발자 입장에서 interface엔 onChange가 열려있는데 왜 동작을 안 하지?,, 라고 오해할 수도 있을 것 같아요!

Copy link
Contributor

Choose a reason for hiding this comment

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

요렇게 할 시에 그러면 두 핸들러 모두 동작하게 하는건가여?

Copy link
Member

Choose a reason for hiding this comment

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

네네! 두 핸들러 모두 동작해요!!

Copy link
Member

Choose a reason for hiding this comment

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

난중에 설명좀 부탁드려요ㅠ 잘 몰루

Copy link
Contributor

Choose a reason for hiding this comment

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

오호 유틸함수 추가해주신걸로 주말에 샴푸님이랑 리팩토링해볼게용

Copy link
Member

Choose a reason for hiding this comment

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

와 이게 뭐에요


import { Text } from '../Text';

interface Props {
labelText: string;
children: string;
Copy link
Member

Choose a reason for hiding this comment

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

요,,요건 언젠가 수정이 필요한ㄷ,,

Copy link
Contributor

Choose a reason for hiding this comment

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

헉걱걱

Comment on lines +9 to +11
type CheckboxContextType = Omit<Props, 'children'>;

export const CheckboxContext = createContext<CheckboxContextType | null>(null);
Copy link
Member

Choose a reason for hiding this comment

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

좋습니다

export function Checkbox({ labelText, checked = false, disabled = false, onChange }: Props) {
export function Checkbox({ children, checked = false, disabled = false, value, onChange }: Props) {

const context = useContext(CheckboxContext);
Copy link
Member

Choose a reason for hiding this comment

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

useContext를 context선언한 곳에서 불러오는건 어떨까요?

Copy link
Member Author

Choose a reason for hiding this comment

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

CheckboxGroup에서 불러온다는 말씀이실까요?

Copy link
Member

Choose a reason for hiding this comment

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

context로 분리하면 그때 같이 요것도 넣어두면 좋을 것 같아요

Comment on lines +21 to +24
if (context) {
checked = context.selectedValue.includes(value);
onChange = context.onChange;
}
Copy link
Member

Choose a reason for hiding this comment

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

난중에 설명좀 부탁드려요ㅠ 잘 몰루

export function CheckboxGroup({ children, ...restProps }: Props) {
return (
<CheckboxContext.Provider value={{ ...restProps }}>
<fieldset className="flex flex-col gap-2">{children}</fieldset>
Copy link
Member

Choose a reason for hiding this comment

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

나중에 row, col 선택할 수 있게 추가하는건 어떨까요?

Copy link
Contributor

Choose a reason for hiding this comment

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

원 헌드레드 퍼센트 동의합니닷

Copy link
Member

Choose a reason for hiding this comment

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

저도 동의,,!

import cx from 'classnames';
import { twMerge } from 'tailwind-merge';
import CheckIcon from '@material-design-icons/svg/outlined/check.svg';
import { CheckboxContext } from './CheckboxGroup';
Copy link
Member

Choose a reason for hiding this comment

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

이거 왜 한 칸이 띄워졌을까요?!

Copy link
Member Author

Choose a reason for hiding this comment

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

프리티어가 안 먹혀있었나 보네요ㅠ

Copy link
Member

@chichoon chichoon left a comment

Choose a reason for hiding this comment

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

체크박스 그룹에서 useContext 사용하신 이유가 하위 체크박스들 상태 보고 배열에 추가하려고 하신건가요

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants