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

implement List molecule component/#18 #27

Merged
merged 18 commits into from
Feb 22, 2024
Merged

Conversation

gahyuun
Copy link
Member

@gahyuun gahyuun commented Feb 16, 2024

๐Ÿ“Œ ์ž‘์—… ๋‚ด์šฉ

๊ตฌํ˜„ ๋‚ด์šฉ ๋ฐ ์ž‘์—… ํ–ˆ๋˜ ๋‚ด์—ญ

  • list molecule component ๊ตฌํ˜„
    ์ถ”๊ฐ€,์‚ญ์ œ ๋ฒ„ํŠผ์ด list row์— ์กด์žฌํ•  ์ˆ˜ ์žˆ๋„๋ก ์ˆ˜์ •์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค!
    ์ด ๋ถ€๋ถ„์€ ๊ธฐ์ด์ˆ˜ ๊ณผ๋ชฉ ์‚ญ์ œ ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•˜๋ฉด์„œ ์ˆ˜์ • ํ•  ์˜ˆ์ •์ž…๋‹ˆ๋‹ค

๐Ÿค” ๊ณ ๋ฏผ ํ–ˆ๋˜ ๋ถ€๋ถ„

  • list row ์ปดํฌ๋„ŒํŠธ์—์„œ column์ด ์ผ์ •ํ•˜๊ฒŒ ์ •ํ•ด์ง„ ํฌ๊ธฐ๋ฅผ ๊ฐ€์ ธ์•ผํ•ฉ๋‹ˆ๋‹ค. ์ฒ˜์Œ์—๋Š” table ํƒœ๊ทธ๋ฅผ ์‚ฌ์šฉํ•ด์„œ table-layout: fixed;
    ์†์„ฑ์„ ์‚ฌ์šฉํ•˜๋ ค ํ–ˆ์ง€๋งŒ, ์•„๋ž˜ ๋‘ ๊ฐ€์ง€ ์ด์œ ๋กœ ๊ธฐ์กด ์กธ๋ถ€ ์ฝ”๋“œ๋ž‘ ๋น„์Šทํ•˜๊ฒŒ width 19%, width 33%๋กœ ๊ฐ€์ ธ๊ฐ”์Šต๋‹ˆ๋‹ค
    ๋” ์ข‹์€ ๋ฐฉ๋ฒ•์ด ์žˆ์„๊นŒ์š”?
  1. table ์‚ฌ์šฉ์‹œ rounded ์ ์šฉ ๋ฌธ์ œ
  2. list row๋งŒ ์‚ฌ์šฉํ•˜๋Š” ์ปดํฌ๋„ŒํŠธ ์กด์žฌ

๐Ÿ”Š ๋„์›€์ด ํ•„์š”ํ•œ ๋ถ€๋ถ„

  • select component์™€ ์•„๋ž˜ ๋‘ ์•„ํ‹ฐํด์„ ์ฐธ๊ณ ํ•ด์„œ compound component pattern์„ ์ ์šฉํ•ด๋ณด์•˜์Šต๋‹ˆ๋‹ค!
    object.assign ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š”๊ฒŒ ๋” ํ•œ ๋ˆˆ์— ๋“ค์–ด์˜ค๋Š” ๊ฒƒ ๊ฐ™์•„์„œ ์‚ฌ์šฉํ•˜์ง€๋Š” ์•Š์•˜๋Š”๋ฐ, select component๋ž‘ ๋น„์Šทํ•œ ๊ตฌํ˜„ ๋ฐฉ์‹์„ ๊ฐ€์ ธ๊ฐ€๋Š”๊ฒŒ ํ†ต์ผ์„ฑ์— ๋” ์ข‹์„๊นŒ์š”??
    https://fe-developers.kakaoent.com/2022/220731-composition-component/
    https://im-developer.tistory.com/238

@gahyuun gahyuun self-assigned this Feb 16, 2024
Copy link

Comment on lines 9 to 13
export function List({ children }: ListProps) {
const getChildren = (type: typeof ListHeader | typeof ListRow) => {
const childrenArray = Children.toArray(children);
return childrenArray.filter((child) => isValidElement(child) && child.type === type);
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

[request change]

  • ์ด๋ ‡๊ฒŒ ํ•จ์ˆ˜ํ˜• ์ปดํฌ๋„ŒํŠธ ๋‚ด๋ถ€์— ํ•จ์ˆ˜๋ฅผ ์„ ์–ธํ•˜๋ฉด, ๋ฆฌ๋ Œ๋”๋งํ•  ๋•Œ๋งˆ๋‹ค ํ•จ์ˆ˜๊ฐ€ ์žฌ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค.
  • ํ•ด๋‹น ํ•จ์ˆ˜๋Š” List ํ•จ์ˆ˜ ๋ฐ”๊นฅ์œผ๋กœ ๋นผ๋„ ๋ฌธ์ œ๊ฐ€ ์—†์–ด ๋ณด์—ฌ์„œ ๋นผ๋Š”๊ฒŒ ์ข‹์•„ ๋ณด์ž…๋‹ˆ๋‹ค.

Copy link
Member Author

Choose a reason for hiding this comment

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

๋””ํ…Œ์ผ์„ ์‹ ๊ฒฝ์“ฐ์ง€ ๋ชปํ–ˆ๋„ค์š” ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค!
91f3565

key={index}
className={twMerge(
'text-[#7590ff] leading-4 text-lg font-bold w-[19%] text-center',
columns.length === 5 ? 'w-[19%]' : 'w-[33%]',
Copy link
Collaborator

@seonghunYang seonghunYang Feb 17, 2024

Choose a reason for hiding this comment

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

[request change]

  • ํ•ด๋‹น ์ƒํ™ฉ์—๋Š” grid๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™๋„ค์š”! width๋กœ ์„ค์ •ํ•˜๋Š”๊ฑด ์ œ๊ฐ€ ํ–ˆ๊ฒ ์ง€๋งŒ ๋ณ„๋กœ์ธ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

children: ReactNode;
};

export function List({ children }: ListProps) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

[comment]

  • ๋ฆฌ์ŠคํŠธ์—์„œ๋Š” ์ปดํŒŒ์šด๋“œ ํŒจํ„ด๊ณผ ๋น„์Šทํ•œ ๋ฐฉ์‹์œผ๋กœ ๋ Œ๋” ํ”„๋กญ์Šค ํŒจํ„ด์„ ์ž์ฃผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
  • ์ด ํŒจํ„ด์„ ์‚ฌ์šฉํ•˜๋ฉด, ์ปดํŒŒ์šด๋“œ ํŒจํ„ด์ฒ˜๋Ÿผ ์˜์กด์„ฑ์„ ์—ญ์ „์‹œํ‚ค๊ณ  ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋ถ„๋ฆฌํ•˜๋Š” ์žฅ์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค.
  • ๋˜ํ•œ, list์™€ ๊ฐ™์€ ์ž๋ฃŒ๊ตฌ์กฐ์™€ UI์— ์ ํ•ฉํ•œ ํŒจํ„ด์ž…๋‹ˆ๋‹ค.
  • ๋งํฌ๋ฅผ ์ฒจ๋ถ€ํ•˜๋‹ˆ, ํ•œ๋ฒˆ ํ™•์ธํ•˜์‹œ๊ณ  ์ด ํŒจํ„ด์ด ์ข‹์•„๋ณด์ด๋ฉด ์ ์šฉํ•ด๋„ ์ข‹์„ ๋“ฏ ํ•˜๋„ค์š”!
  • https://www.patterns.dev/react/render-props-pattern

Comment on lines 23 to 24
List.Header = ListHeader;
List.Row = ListRow;
Copy link
Collaborator

@seonghunYang seonghunYang Feb 17, 2024

Choose a reason for hiding this comment

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

[comment]

  • ์ €๋Š” ๊ฐ€๋…์„ฑ ์ธก๋ฉด์—์„œ assign์„ ์‚ฌ์šฉํ•˜๋Š”๊ฒŒ ๋” ์ข‹๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ์–ด์š”!
  • ๊ฐ๊ฐ ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๋”ฐ๋กœ ์‚ฌ์šฉ๋˜๋Š”๊ฒŒ ์•„๋‹ˆ๋ผ ์ปดํŒŒ์šดํŠธ ํŒจํ„ด์ด ์ ์šฉ๋œ ์„œ๋ธŒ ์ปดํฌ๋„ŒํŠธ์ž„์ด ๋” ๋ช…ํ™•ํ•˜๊ฒŒ ๋“œ๋Ÿฌ๋‚˜๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.
  • ์•„๋ž˜ ๋งํฌ์—์„œ ์˜๊ฐ์„ ์–ป์—ˆ์–ด์„œ ์ฒจ๋ถ€ํ• ๊ฒŒ์š”
    https://fe-developers.kakaoent.com/2022/220731-composition-component/#3-3-%EB%A9%94%EC%9D%B8--%EC%84%9C%EB%B8%8C-%EC%BB%B4%ED%8F%AC%EB%84%8C%ED%8A%B8%EB%A5%BC-%EB%AC%B6%EC%96%B4%EC%84%9C-export
  • (๊ทธ๋ฆฌ๊ณ  ์‚ฌ์‹ค ์ด๊ฑด ์ •ํ™•ํžˆ ๊ธฐ์–ต์€ ์•ˆ๋‚˜๋Š”๋ฐ assign์„ ์‚ฌ์šฉํ•ด์•ผํ•˜๋Š” ๋˜ ๋‹ค๋ฅธ ๊ธฐ์ˆ ์  ์ด์œ ๋„ ์žˆ์—ˆ๋˜ ๊ฒƒ ๊ฐ™์•„์š”. ์ฐพ์œผ๋ฉด ์ด๊ฑด ๋‹ค์‹œ ๋ง์”€๋“œ๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค)

columns: string[];
};

export function ListHeader({ columns }: ListHeaderProps) {
Copy link
Collaborator

@seonghunYang seonghunYang Feb 17, 2024

Choose a reason for hiding this comment

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

[requset change]

  • named export๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋‚ด๋ณด๋‚ด๋Š” ๊ฒƒ์„ ์ง€ํ–ฅํ•˜๋Š” ์ด์œ ๊ฐ€ ์žˆ๋‚˜์š”?
  • ์ €๋Š” React์™€ Next์—์„œ ๊ธฐ๋ณธ์ ์œผ๋กœ ์ƒ์„ฑํ•˜๋Š” ํ…œํ”Œ๋ฆฟ์ด export default์ด๊ธฐ ๋•Œ๋ฌธ์—, ์ด๋ฅผ ํ‘œ์ค€์œผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์„ ์ œ์•ˆํ•ฉ๋‹ˆ๋‹ค.
  • ๋˜ํ•œ, ์ถ”๊ฐ€์ ์œผ๋กœ ์ปดํŒŒ์šด๋“œ ํŒจํ„ด์„ ์‚ฌ์šฉํ•  ๋•Œ๋Š”, ํ•˜์œ„ ์ปดํฌ๋„ŒํŠธ์— named export๋ฅผ ์‚ฌ์šฉํ•˜๊ณ , ์ปดํŒŒ์šด๋“œ ํŒจํ„ด์˜ ๋ฃจํŠธ ์ปดํฌ๋„ŒํŠธ์—๋Š” default export๋ฅผ ์ ์šฉํ•˜๋ฉด ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋ถ„๋ฆฌํ•˜๋Š” ๊ฒƒ์ด ๋” ๋ช…ํ™•ํ•ด์งˆ ๊ฒƒ์ด๋ผ๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.

Copy link
Collaborator

Choose a reason for hiding this comment

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

  • ์ถ”๊ฐ€๋กœ, default export๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ํŒŒ์ผ์ด ํ•˜๋‚˜์˜ ์ฑ…์ž„๋งŒ์„ ๊ฐ€์ง€๋„๋ก ์–ด๋Š ์ •๋„ ๊ฐ•์ œํ•  ์ˆ˜ ์žˆ์–ด ์ข‹๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.
  • ๋งŒ์•ฝ ์ปดํฌ๋„ŒํŠธ ํŒŒ์ผ์—์„œ ์—ฌ๋Ÿฌ ํ•จ์ˆ˜๋‚˜ ํƒ€์ž… ์ปดํฌ๋„ŒํŠธ๋ฅผ exportํ•˜๊ณ  ์žˆ๋‹ค๋ฉด, ๊ด€์‹ฌ์‚ฌ์˜ ๋ถ„๋ฆฌ๊ฐ€ ์ž˜ ์ด๋ฃจ์–ด์ง€์ง€ ์•Š์•˜๋‹ค๊ณ  ํŒ๋‹จ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์ด๋ฅผ ๋ฐฉ์ง€ํ•˜๋Š” ๋ฐ์—๋„ ์œ ์šฉํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.

Copy link
Member Author

@gahyuun gahyuun Feb 18, 2024

Choose a reason for hiding this comment

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

List์˜ ๊ฒฝ์šฐ์—๋Š” default export๋ฅผ ์ ์šฉํ–ˆ์„ ๋•Œ ์•„๋ž˜ ๋ฌธ์ œ๊ฐ€ ์žˆ๋Š” ๊ฑธ ํ™•์ธํ–ˆ์Šต๋‹ˆ๋‹ค

  • List๋Š” List header์™€ List row๋ผ๋Š” ์ปดํฌ๋„ŒํŠธ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋Š”๋ฐ export default๋งŒ ํ•ด์ค„ ๊ฒฝ์šฐ List component๋งŒ export๋ฅผ ํ•ด์ฃผ๊ธฐ์— story book์—์„œ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค
  • ๊ทธ๋ž˜์„œ List์˜ ๊ฒฝ์šฐ์—๋Š” default export๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค

์ถ”๊ฐ€์ ์œผ๋กœ ๊ถ๊ธˆํ•œ ๊ฒŒ ์žˆ๋Š”๋ฐ, compound pattern์— ์žˆ์–ด์„œ ํ•˜์œ„ ์ปดํฌ๋„ŒํŠธ๋ผ๋Š” named export๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒŒ ๋” ๋ช…ํ™•ํ•ด์งˆ๊ฑฐ๋ผ๊ณ  ๋ง์”€ํ•˜์…จ๋Š”๋ฐ ํ•˜์œ„ ์ปดํฌ๋„ŒํŠธ๋ผ๋„ ํŒŒ์ผ์—์„œ๋Š” ํ•˜๋‚˜์˜ ์ฑ…์ž„๋งŒ ๊ฐ€์ง€๋ฏ€๋กœ default export ๋ฅผ ์ ์šฉํ•˜๋Š” ๊ฒŒ ๋” ์ข‹์ง€์•Š์„๊นŒ์š”??

Copy link
Collaborator

Choose a reason for hiding this comment

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

์ €๋„ ์ด์™€ ๋น„์Šทํ•œ ๋ฌธ์ œ๋ฅผ ์ด์ „์— ๊ฒฝํ—˜ํ•œ ์ ์ด ์žˆ์—ˆ๋˜ ๊ฒƒ ๊ฐ™๋„ค์š”. ์ œ๊ฐ€ ์‚ฌ์šฉํ•œ select ์ปดํฌ๋„ŒํŠธ์ฒ˜๋Ÿผ, index ํŒŒ์ผ์—์„œ assign์œผ๋กœ ๋ฌถ์–ด์„œ export default๋ฅผ ์‚ฌ์šฉํ•ด ๋ณด์‹œ๋Š” ๊ฑด ์–ด๋–จ๊นŒ์š”?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Compound ํŒจํ„ด์—์„œ ํ•˜์œ„ ์ปดํฌ๋„ŒํŠธ์— named export๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์„ ์ œ์•ˆํ•˜๋Š” ์ด์œ ๋Š”, ๋…๋ฆฝ์ ์œผ๋กœ ์‚ฌ์šฉ๋˜๋Š” ์ปดํฌ๋„ŒํŠธ๋Š” ๋ชจ๋‘ default export๋ฅผ ํ•˜๊ณ , ํ•˜์œ„ ์ปดํฌ๋„ŒํŠธ๋Š” named export๋ฅผ ์‚ฌ์šฉํ•˜๊ฒŒ ๋˜๋ฉด, ๋‹ค๋ฅธ ๊ณณ์—์„œ import ํ•  ๋•Œ ์ด ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๋…๋ฆฝ๋œ ์ปดํฌ๋„ŒํŠธ์ธ์ง€, ์•„๋‹ˆ๋ฉด ํ•˜์œ„ ์ปดํฌ๋„ŒํŠธ์ธ์ง€ ๋ช…ํ™•ํ•˜๊ฒŒ ๊ตฌ๋ถ„ํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

import ListHeader from '../../..';  // ํ•˜์œ„ ์ปดํฌ๋„ŒํŠธ์ธ์ง€ ์•Œ ์ˆ˜ ์—†์Œ

import { ListHeader } from '../../'; // ListHeader๋Š” ํ•˜์œ„ ์ปดํฌ๋„ŒํŠธ์ž„์„ ์•Œ ์ˆ˜ ์žˆ์Œ
import List from '../../';   // List๋Š” ๋…๋ฆฝ์ ์ธ ์ปดํฌ๋„ŒํŠธ์ž„์„ ์•Œ ์ˆ˜ ์žˆ์Œ

์ด์™€ ๋™์ผํ•œ ์ด์œ ๋กœ, ๋…๋ฆฝ์ ์ธ ์ปดํฌ๋„ŒํŠธ๋Š” default export๋กœ ํ†ต์ผํ•˜๋ฉด ๊ตฌ๋ถ„์ด ๋”์šฑ ๋ช…ํ™•ํ•ด์ง‘๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ List ์ปดํฌ๋„ŒํŠธ๋ฅผ export default๋กœ ๋ณ€๊ฒฝํ•˜๋Š” ๊ฒƒ์ด ์ข‹์•„ ๋ณด์ž…๋‹ˆ๋‹ค!

yougyung
yougyung previously approved these changes Feb 18, 2024
import { ListHeader } from './list-header';
import { ListRow } from './list-row';

type ListProps = {
Copy link
Member

Choose a reason for hiding this comment

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

type ๋ฐ interface ์ค‘ ์ ์šฉํ•˜์‹œ๋Š” ๊ธฐ์ค€์ด ์žˆ์œผ์‹ ๊ฐ€์š”?

Copy link
Member Author

Choose a reason for hiding this comment

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

interface๋‚˜ type ์–ด๋–ค ๊ฑธ ์‚ฌ์šฉํ•˜๋˜ ์ƒ๊ด€์ด ์—†์„ ๋•Œ๋Š” ํ†ต์ผ์„ฑ์„ ์œ„ํ•ด ํŒ€์›๋“ค๊ณผ ๋งž์ถฐ ์‚ฌ์šฉํ•˜๋Š” ํŽธ์ž…๋‹ˆ๋‹ค
ํ•ด๋‹น ์ฝ”๋“œ์—์„œ๋Š” select component์™€ ํ†ต์ผ์„ฑ์„ ์œ„ํ•ด์„œ type์„ ์‚ฌ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค!

@yougyung
Copy link
Member

list molecule component ๊ตฌํ˜„
์ถ”๊ฐ€,์‚ญ์ œ ๋ฒ„ํŠผ์ด list row์— ์กด์žฌํ•  ์ˆ˜ ์žˆ๋„๋ก ์ˆ˜์ •์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค!
์ด ๋ถ€๋ถ„์€ ๊ธฐ์ด์ˆ˜ ๊ณผ๋ชฉ ์‚ญ์ œ ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•˜๋ฉด์„œ ์ˆ˜์ • ํ•  ์˜ˆ์ •์ž…๋‹ˆ๋‹ค

๋ฒ„ํŠผ ๊ธฐ๋Šฅ์€ ์ˆœ์ˆ˜ํ•˜๊ฒŒ list๊ฐ€ ํ•˜๋Š” ์—ญํ• ์ด ์•„๋‹Œ๋ฐ, ๊ธฐ์กด ์ฝ”๋“œ์—์„œ๋Š” ์—ญํ•  ์ด์ƒ์„ list component๊ฐ€ ํ•ด์ฃผ๊ณ  ์žˆ๋‹ค๊ณ  ๋Š๊ผˆ์Šต๋‹ˆ๋‹ค. ๋ฆฌ์ŠคํŠธ๋‚ด ๋ฒ„ํŠผ ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•˜๊ธฐ ์œ„ํ•ด์„œ ๋˜ ๋‹ค๋ฅธ ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์–ด์•ผํ•˜์ง€๋งŒ, list component์— button์ด ์—†๋Š” ํ˜„์žฌ ์ƒํƒœ๋„ ์ถฉ๋ถ„ํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.

Copy link

@gahyuun
Copy link
Member Author

gahyuun commented Feb 18, 2024

list molecule component ๊ตฌํ˜„
์ถ”๊ฐ€,์‚ญ์ œ ๋ฒ„ํŠผ์ด list row์— ์กด์žฌํ•  ์ˆ˜ ์žˆ๋„๋ก ์ˆ˜์ •์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค!
์ด ๋ถ€๋ถ„์€ ๊ธฐ์ด์ˆ˜ ๊ณผ๋ชฉ ์‚ญ์ œ ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•˜๋ฉด์„œ ์ˆ˜์ • ํ•  ์˜ˆ์ •์ž…๋‹ˆ๋‹ค

๋ฒ„ํŠผ ๊ธฐ๋Šฅ์€ ์ˆœ์ˆ˜ํ•˜๊ฒŒ list๊ฐ€ ํ•˜๋Š” ์—ญํ• ์ด ์•„๋‹Œ๋ฐ, ๊ธฐ์กด ์ฝ”๋“œ์—์„œ๋Š” ์—ญํ•  ์ด์ƒ์„ list component๊ฐ€ ํ•ด์ฃผ๊ณ  ์žˆ๋‹ค๊ณ  ๋Š๊ผˆ์Šต๋‹ˆ๋‹ค. ๋ฆฌ์ŠคํŠธ๋‚ด ๋ฒ„ํŠผ ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•˜๊ธฐ ์œ„ํ•ด์„œ ๋˜ ๋‹ค๋ฅธ ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์–ด์•ผํ•˜์ง€๋งŒ, list component์— button์ด ์—†๋Š” ํ˜„์žฌ ์ƒํƒœ๋„ ์ถฉ๋ถ„ํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.

์ €๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด ์ฝ”๋“œ๋ฅผ ๊ตฌํ˜„ํ•˜๋ ค ํ–ˆ์Šต๋‹ˆ๋‹ค

    const rowColumns = ['HEC01302', '๋ถ„์‚ฐํ”„๋กœ๊ทธ๋ž˜๋ฐ', '3'];
    return (
      <div>
        <List>
          <List.Row columns={rowColumns} invalid={true} actionButton ={<Button></Button>} />
        </List>
      </div>
    );
    
export function ListRow({ columns, invalid = false, actionButton}: ListRowProps) {
  return (
    <div className="flex border-solid border-gray-300 border-b-[1px] items-center last:border-b-0">
      {columns.map((column, index) => (
        <div
          key={index}
          className={twMerge(
            'text-center my-4 font-medium text-lg text-[#2f2f2f]',
            columns.length === 5 ? 'w-[19%]' : 'w-[33%]',
            invalid ? 'text-red-500' : 'text-[#2f2f2f]',
          )}
        >
          {column}
        </div>
      ))}
      {actionButton}
    </div>
  );
}

์œ„ ๋ฐฉ์‹์€ button์„ ์œ„ํ•œ component๋ฅผ ๊ตฌํ˜„ํ•œ ๊ฒŒ ์•„๋‹ˆ๊ณ  ๋‹จ์ง€ list๊ฐ€ trigger ์—ญํ• ์„ ํ•œ๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค!
ํ˜น์‹œ ์ด ๋ฐฉ์‹์ด list component๊ฐ€ ์—ญํ•  ์ด์ƒ์„ ํ•ด์ค€๋‹ค๊ณ  ์ƒ๊ฐํ•˜์‹  ๊ฒŒ ๋งž์„๊นŒ์š”? ๋งž๋‹ค๋ฉด button์„ ์œ„ํ•ด list๋ฅผ ์–ด๋–ค ๋ฐฉ์‹์œผ๋กœ ์ˆ˜์ •ํ•˜๋Š” ๊ฑธ ์„ ํ˜ธํ•˜์‹œ๋Š” ์ง€ ์ข€ ๋” ๋ง์”€ํ•ด์ฃผ์‹ค ์ˆ˜ ์žˆ๋‚˜์š”?

Copy link

@seonghunYang
Copy link
Collaborator

์œ ๊ฒฝ ์”จ์˜ ์˜๊ฒฌ๊ณผ ๋น„์Šทํ•œ๋ฐ, actionbutton๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ListRow ์ปดํฌ๋„ŒํŠธ์— invalid ์†์„ฑ์ด ์žˆ๋Š” ๊ฒƒ์ด ์กฐ๊ธˆ ์–ด์ƒ‰ํ•˜๊ฒŒ ๋Š๊ปด์ง‘๋‹ˆ๋‹ค. ๋‘ ์†์„ฑ ๋ชจ๋‘ List์™€ ListRow๋ณด๋‹ค๋Š” ๊ธฐ์ด์ˆ˜ ๊ณผ๋ชฉ ๋ฆฌ์ŠคํŠธ๋ฅผ ์œ„ํ•œ ์†์„ฑ์ด๋ผ์„œ ๊ทธ๋Ÿฐ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ์ œ ์ƒ๊ฐ์—๋Š” ๋‹ค์Œ ๋‘ ๊ฐ€์ง€ ๋ฐฉ์•ˆ์ด ์žˆ์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค:

  1. List, ListRow ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋„๋ฉ”์ธ ์ปดํฌ๋„ŒํŠธ๋กœ ๋ณ€๊ฒฝ - invalid, actionButton ์†์„ฑ์€ ๋ฒ”์šฉ์ ์ธ list ์ปดํฌ๋„ŒํŠธ๋ณด๋‹ค๋Š” ๊ธฐ์ด์ˆ˜ ๊ณผ๋ชฉ ๋ฆฌ์ŠคํŠธ์— ํ•ด๋‹นํ•˜๋Š” ๋‚ด์šฉ์ด๋ฏ€๋กœ, ์ด๋ฅผ ๋„๋ฉ”์ธ ์ปดํฌ๋„ŒํŠธ๋กœ ๋ณ€๊ฒฝ
  2. ์ปดํฌ๋„ŒํŠธ ๊ณ„์ธตํ™” - List, ListRow๋ฅผ ์žฌ์‚ฌ์šฉ ๋ฐ ํ™•์žฅ ๊ฐ€๋Šฅํ•œ ๋ทฐ ์ปดํฌ๋„ŒํŠธ๋กœ ๋ฆฌํŒฉํ† ๋งํ•˜์—ฌ ๋ณธ๋ž˜์˜ List, ListRow ๊ธฐ๋Šฅ์— ์ง‘์ค‘ํ•˜๊ณ , ์ด๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ๊ธฐ์ด์ˆ˜ ๊ณผ๋ชฉ ๋ฆฌ์ŠคํŠธ ๋„๋ฉ”์ธ ์ปดํฌ๋„ŒํŠธ๋ฅผ ๊ตฌํ˜„

์„ธ ๋ถ„ ๋ชจ๋‘ ๊ด€๋ จ ์‚ฌ์•ˆ์— ๋Œ€ํ•œ ์˜๊ฒฌ์„ ์ฃผ์…จ์œผ๋‹ˆ ์ฑ„ํŒ…์œผ๋กœ ์ง„ํ–‰ํ•˜๋Š” ๊ฒƒ๋„ ์ข‹์ง€๋งŒ, ์‹œ๊ฐ„์ด ์ง€์ฒด๋  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ ๋ณด์ด์Šค๋กœ ํ•œ ๋ฒˆ ์ด์•ผ๊ธฐํ•ด ๋ณด๋Š” ๊ฒƒ์€ ์–ด๋–จ๊นŒ์š”?

Copy link

Copy link

@gahyuun
Copy link
Member Author

gahyuun commented Feb 21, 2024

@yougyung @seonghunYang list component ๋ฆฌํŒฉํ† ๋ง์„ ํ•ด์„œ push ํ–ˆ์Šต๋‹ˆ๋‹ค! ๊ตฌํ˜„ํ•˜๋ฉด์„œ ์•„๋ž˜์™€ ๊ฐ™์€ ์ ๋“ค์„ ๋Š๊ผˆ์Šต๋‹ˆ๋‹ค

  • grid component ๋งŒํผ ๋‹ค๋ฅธ ์ปดํฌ๋„ŒํŠธ๋ฅผ ์ถ”์ƒํ™”ํ•  ์ˆ˜ ์žˆ์„๊นŒ? grid component์˜ ์—ญํ• ์ด ์ปดํฌ๋„ŒํŠธ๋กœ ๋ถ„๋ฆฌํ•  ์ •๋„์˜ ์—ญํ• ์ผ๊นŒ? ๋ผ๋Š” ์˜๋ฌธ์ด ์ƒ๊ฒผ์Šต๋‹ˆ๋‹ค.
    ํ•˜์ง€๋งŒ ์—ฌ๊ธฐ์„œ ํฐ ๋ฌธ์ œ๊ฐ€ ๋  ๊ฒƒ ๊ฐ™์ง€ ์•Š๊ณ  grid component๊ฐ€ ์ฃผ๋Š” ์ด์ ๋„ ์žˆ์„ ๊ฒƒ ๊ฐ™์•„์„œ ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค
  • render props pattern์„ ๊ตณ์ด ์ด์šฉํ•ด์•ผ ํ•˜๋Š” ์ด์œ ๋ฅผ ์ž˜ ๋ชจ๋ฅด๊ฒ ์–ด์„œ ์‚ฌ์šฉํ•˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค! children์œผ๋กœ ์‚ฌ์šฉํ•ด๋„ ๋˜๋Š”๋ฐ ๊ตณ์ด render ํ•จ์ˆ˜๋ฅผ ๋งŒ๋“ค์–ด์•ผ ํ•˜๋Š” ์ด์œ ๋ฅผ ๋ชจ๋ฅด๊ฒ ์Šต๋‹ˆ๋‹ค ๋˜ํ•œ List component์—๋งŒ render props ํŒจํ„ด์„ ์ ์šฉํ•˜๊ธฐ์— ์ผ๊ด€์„ฑ์ด ๋–จ์–ด์ง„๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ์Šต๋‹ˆ๋‹ค!

Copy link

Copy link

Copy link

Copy link
Collaborator

@seonghunYang seonghunYang left a comment

Choose a reason for hiding this comment

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

  • ํ™•์ธํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ณ ์ƒํ•˜์…จ์–ด์š”!

@gahyuun gahyuun merged commit a97f6e6 into main Feb 22, 2024
3 checks passed
@gahyuun gahyuun deleted the list-molecule-component/#18 branch February 22, 2024 05:21
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.

3 participants