-
Notifications
You must be signed in to change notification settings - Fork 0
[REFACTOR] Accordion 컴포넌트의 defaultValue prop 지원 #85
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -63,6 +63,7 @@ export const NoneArrowAccordion: Story = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const InputAccordion: Story = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| render: () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -74,3 +75,18 @@ export const InputAccordion: Story = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const DefaultValueAccordion: Story = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| render: () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Accordion type="single" defaultValue={['item-2']}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <AccordionItem value="item-1" isArrow={false} trigger="defualtValue를 설정하지 않은 요소"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 초기 render시 조회되지 않아요 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </AccordionItem> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <AccordionItem value="item-2" isArrow={false} trigger="defualtValue를 설정한 요소"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 초기 render시 조회돼요 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </AccordionItem> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Accordion> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+79
to
+92
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. 스토리 코드는 잘 작동하지만, trigger 텍스트에 오타가 있습니다. 86번 라인에서 두 번째 다음 diff를 적용하여 수정하세요: - <AccordionItem value="item-2" isArrow={false} trigger={<div>질문 1</div>}>
+ <AccordionItem value="item-2" isArrow={false} trigger={<div>질문 2</div>}>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -17,6 +17,11 @@ type AccordionRootProps = { | |||||
| * The content of the Accordion, typically AccordionItem components. | ||||||
| */ | ||||||
| children: ReactNode; | ||||||
| /** | ||||||
| * The default value of the Accordion item that should be open on initial render. | ||||||
| */ | ||||||
| defaultValue?: string[]; | ||||||
|
Comment on lines
+20
to
+23
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. 🧹 Nitpick | 🔵 Trivial 단일 모드에서 타입 안정성을 개선할 수 있습니다.
타입을 조건부로 정의하는 것을 고려해보세요: type AccordionRootProps = {
type?: 'single' | 'multiple';
children: ReactNode;
className?: string;
} & (
| { type?: 'single'; defaultValue?: string }
| { type?: 'multiple'; defaultValue?: string[] }
);또는 더 간단하게 유니온 타입을 사용할 수 있습니다: type AccordionRootProps = {
type?: 'single' | 'multiple';
children: ReactNode;
defaultValue?: string | string[];
className?: string;
};🤖 Prompt for AI Agents |
||||||
|
|
||||||
| /** | ||||||
| * Additional class names to apply to the AccordionRoot. | ||||||
| */ | ||||||
|
|
@@ -27,9 +32,11 @@ export function AccordionRoot({ | |||||
| type = 'single', | ||||||
| className = '', | ||||||
| children, | ||||||
| defaultValue, | ||||||
| ...props | ||||||
| }: AccordionRootProps) { | ||||||
| const [openItems, setOpenItems] = useState<string[]>([]); | ||||||
| const defaultOpenItem = defaultValue ? defaultValue : []; | ||||||
|
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. 🧹 Nitpick | 🔵 Trivial nullish coalescing 연산자로 간소화할 수 있습니다. 현재 삼항 연산자 대신 nullish coalescing 연산자( 다음 diff를 적용하세요: - const defaultOpenItem = defaultValue ? defaultValue : [];
+ const defaultOpenItem = defaultValue ?? [];📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| const [openItems, setOpenItems] = useState<string[]>(defaultOpenItem); | ||||||
|
|
||||||
| const toggleItem = (value: string) => { | ||||||
| if (type === 'single') { | ||||||
|
|
||||||
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.
trigger 텍스트의 오타를 수정하세요.
83번과 86번 라인의 trigger 텍스트에서 "defualtValue"를 "defaultValue"로 수정해야 합니다. 철자 오류가 사용자에게 노출되는 스토리북 문서에 표시됩니다.
다음 diff를 적용하여 수정하세요:
Also applies to: 86-86
🤖 Prompt for AI Agents