-
Notifications
You must be signed in to change notification settings - Fork 4
refactor(Tab): Tab 컴포넌트 storybook 및 접근성 개선 #286
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
base: main
Are you sure you want to change the base?
Changes from all commits
cfc20fe
7599672
d5162a3
cc3f4f5
6773960
8bb121c
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 |
|---|---|---|
|
|
@@ -5,15 +5,45 @@ const meta = { | |
| title: 'Components/Tab', | ||
| component: Tab, | ||
| tags: ['autodocs'], | ||
| parameters: { | ||
| docs: { | ||
| description: { | ||
| component: '동일한 위계의 요소를 그룹화하여 화면이동 없이 빠르게 탐색합니다.', | ||
| }, | ||
| }, | ||
| }, | ||
| args: { | ||
| tabItems: ['Tab1', 'Tab2', 'Tab3'], | ||
| selectedInitial: 'Tab1', | ||
| translator: { Tab1: '탭1', Tab2: '탭2', Tab3: '탭3' }, | ||
| }, | ||
| argTypes: { | ||
| style: { control: 'radio', options: ['primary', 'secondary'] }, | ||
| size: { control: 'radio', options: ['sm', 'md', 'lg'] }, | ||
| selectedInitial: { control: 'select', options: ['Tab1', 'Tab2', 'Tab3'] }, | ||
| tabItems: { | ||
| description: '여러 Tab 항목을 전달합니다.', | ||
| table: { type: { summary: 'T[]' } }, | ||
| }, | ||
| selectedInitial: { | ||
| control: 'select', | ||
| options: ['Tab1', 'Tab2', 'Tab3'], | ||
| description: 'Tab의 초기 선택 값을 설정합니다.', | ||
| table: { type: { summary: 'T (optional)' } }, | ||
| }, | ||
| translator: { | ||
| description: 'Tab 항목의 텍스트를 원하는 컴포넌트로 변경합니다.', | ||
|
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. Tab 항목의 텍스트를 ReactNode로 매핑합니다. (아이콘, 강조 텍스트 등 가능) 와 같이 ReactNode 사용을 명시해줘도 좋을 것 같아요! |
||
| table: { type: { summary: 'Record<T, ReactNode>' } }, | ||
| }, | ||
| style: { | ||
| control: 'inline-radio', | ||
| options: ['primary', 'secondary'], | ||
| description: 'Tab의 스타일을 설정합니다.', | ||
| table: { type: { summary: 'primary | secondary' } }, | ||
| }, | ||
| size: { | ||
| control: 'inline-radio', | ||
| options: ['sm', 'md', 'lg'], | ||
| description: 'Tab의 크기를 설정합니다.', | ||
| table: { type: { summary: 'sm | md | lg' } }, | ||
| }, | ||
|
Comment on lines
+41
to
+46
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. 해당 문서에 defaultValue가 빠진 것 같아요! 이부분 추가해주세요! |
||
| }, | ||
| } as Meta<typeof Tab>; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import type { ReactNode} from 'react'; | ||
| import type { ReactNode } from 'react'; | ||
| import { useState } from 'react'; | ||
| import * as S from './style.css'; | ||
| import { createTabItemVariant, createTabVariant } from './utils'; | ||
|
|
@@ -30,21 +30,24 @@ function Tab<T extends string>(props: TabProps<T>) { | |
| }; | ||
|
|
||
| return ( | ||
| <div className={`${S.tab} ${tabVariant} ${className}`}> | ||
| <div className={`${S.tab} ${tabVariant} ${className}`} role='tablist'> | ||
| {tabItems.map((item) => { | ||
| const isSelected = selected === item ? 'selected' : ''; | ||
| const isSelected = selected === item; | ||
| return ( | ||
| <div className={S.tabItemWrap} key={item}> | ||
| <button | ||
| className={`${S.tabItem} ${tabItemVariant} ${isSelected} ${S.fontStyles[size]}`} | ||
| aria-selected={isSelected} | ||
| className={`${S.tabItem} ${tabItemVariant} ${isSelected ? 'selected' : ''} ${S.fontStyles[size]}`} | ||
| onClick={() => { | ||
| handleClickTabItem(item); | ||
| }} | ||
| role='tab' | ||
| tabIndex={isSelected ? 0 : -1} | ||
| type='button' | ||
| > | ||
| {translator ? translator[item] : item} | ||
| </button> | ||
| <div className={`${S.tabItemUnderline} ${isSelected}`} /> | ||
| <div className={`${S.tabItemUnderline} ${isSelected ? 'selected' : ''}`} /> | ||
|
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. selected className이 어떤 용도로 활용되는건가요??
Member
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. 수정하신 위 재훈님이 말씀하신 것도 동의합니다 |
||
| </div> | ||
| ); | ||
| })} | ||
|
|
@@ -53,3 +56,5 @@ function Tab<T extends string>(props: TabProps<T>) { | |
| } | ||
|
|
||
| export default Tab; | ||
|
|
||
| Tab.displayName = 'Tab'; | ||
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.
story는 구체적인 타입이나 예시를 넣는것이 문서를 읽는데 더 좋은 방향인 것 같아요 제네릭 타입보단 string[] 을 사용해보는건 어떤가요?