-
Notifications
You must be signed in to change notification settings - Fork 2
Feat(client): ParentTagList 컴포넌트 구현 #292
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,33 +2,37 @@ import { ButtonHTMLAttributes } from 'react'; | |
|
|
||
| import { Icon, IconName } from '@cds/icon'; | ||
|
|
||
| import * as styles from './sidebar-item.css'; | ||
| import * as styles from './nav-item.css'; | ||
|
|
||
| interface SidebarItemProps extends Pick< | ||
| interface NavItemProps extends Pick< | ||
| ButtonHTMLAttributes<HTMLButtonElement>, | ||
| 'onClick' | 'disabled' | ||
| > { | ||
| iconName: IconName; | ||
| content?: string; | ||
| isSelected?: boolean; | ||
| type?: 'sm' | 'lg'; | ||
| } | ||
|
|
||
| const SidebarItem = ({ | ||
| const NavItem = ({ | ||
|
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. 어떤 컴포넌트 이름을 하게되든 이 컴포넌트 props가 ButtonHTMLAttributes를 상속받는다고 예상하기 어려워용 onClick과 disabled도 props로 직접 드러내면 좋을 것 같아요! |
||
| iconName, | ||
| content, | ||
| isSelected, | ||
| type = 'lg', | ||
|
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. type 대신 iconSize를 보내면 좋아보여요 추가적으로 만약에 10개의 사용처에서 서로 다른 type을 요구한다면 type이 점점 커질 거에요
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. css 파일을 보니까 type에 따라 스타일을 다르게 적용하고 있네용 |
||
| ...props | ||
| }: SidebarItemProps) => { | ||
| }: NavItemProps) => { | ||
| return ( | ||
| <button | ||
| {...props} | ||
| type="button" | ||
| className={styles.container({ isSelected })} | ||
| > | ||
| <Icon name={iconName} size={32} /> | ||
| {content != null && <span className={styles.text}>{content}</span>} | ||
| <Icon name={iconName} size={type === 'lg' ? 32 : 24} /> | ||
| {content != null && ( | ||
| <span className={styles.text({ type })}>{content}</span> | ||
| )} | ||
| </button> | ||
| ); | ||
| }; | ||
|
|
||
| export default SidebarItem; | ||
| export default NavItem; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { style } from '@vanilla-extract/css'; | ||
|
|
||
| import { themeVars } from '@cds/ui'; | ||
|
|
||
| export const container = style({ | ||
| position: 'relative', | ||
| height: '100%', | ||
| maxHeight: '25.6rem', | ||
| padding: '0.4rem 1.8rem 0.4rem 0', | ||
| borderRight: `1px solid ${themeVars.color.grey200}`, | ||
| overflowY: 'auto', | ||
| overflowX: 'hidden', | ||
| }); | ||
|
|
||
| export const list = style({ | ||
| display: 'flex', | ||
| flexDirection: 'column', | ||
| gap: '0.4rem', | ||
| width: '13.2rem', | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import { TagNode } from '@shared/apis/tag/type'; | ||
| import NavItem from '@shared/components/nav-item/nav-item'; | ||
|
|
||
| import * as styles from './parent-tag-list.css'; | ||
|
|
||
| interface ParentTagListProps { | ||
| tags: TagNode[]; | ||
| selectedTagId: number; | ||
| onSelect: (tagId: number) => void; | ||
| } | ||
|
|
||
| const ParentTagList = ({ | ||
| tags, | ||
| selectedTagId, | ||
| onSelect, | ||
| }: ParentTagListProps) => { | ||
| return ( | ||
| <div className={styles.container}> | ||
| <ul className={styles.list}> | ||
| {tags.map(({ tagId, name }) => ( | ||
| <li key={tagId}> | ||
| <NavItem | ||
| type="sm" | ||
| iconName="ic_tag" | ||
| content={name} | ||
| isSelected={selectedTagId === tagId} | ||
| onClick={() => onSelect(tagId)} | ||
| /> | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default ParentTagList; |
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.
MenuItem 어떠신가요?
Nav의 navigation은 페이지 이동이 가능하다는 의미를 함축하고 있어서,
shared 컴포넌트로 사용한다면 Menu처럼 더 추상적인 개념으로 접근하면 좋을 것 같아요