-
Notifications
You must be signed in to change notification settings - Fork 0
[REFACTOR] 아코디언 컴포넌트 아이콘 위치 조정 및 크기 조정 #139
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 | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -26,13 +26,18 @@ type AccordionRootProps = { | |||||||||||||||||||||
| * Additional class names to apply to the AccordionRoot. | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| className?: string; | ||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * Default icon size for all AccordionItems. | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| iconSize?: number; | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export function AccordionRoot({ | ||||||||||||||||||||||
| type = 'single', | ||||||||||||||||||||||
| className = '', | ||||||||||||||||||||||
| children, | ||||||||||||||||||||||
| defaultValue, | ||||||||||||||||||||||
| iconSize, | ||||||||||||||||||||||
| ...props | ||||||||||||||||||||||
| }: AccordionRootProps) { | ||||||||||||||||||||||
| const defaultOpenItem = defaultValue ? defaultValue : []; | ||||||||||||||||||||||
|
|
@@ -49,7 +54,7 @@ export function AccordionRoot({ | |||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| return ( | ||||||||||||||||||||||
| <AccordionContext.Provider value={{ openItems, toggleItem, type }}> | ||||||||||||||||||||||
| <AccordionContext.Provider value={{ openItems, toggleItem, type, iconSize }}> | ||||||||||||||||||||||
| <div className={cn(`w-full`, className)} {...props}> | ||||||||||||||||||||||
| {children} | ||||||||||||||||||||||
| </div> | ||||||||||||||||||||||
|
|
@@ -83,6 +88,24 @@ type AccordionItemProps = { | |||||||||||||||||||||
| * The class name for the content container. | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| contentClassName?: string; | ||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * Additional class names for the arrow icon wrapper. | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| iconWrapperClassName?: string; | ||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * Additional class names for the SVG arrow icon itself. | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| iconClassName?: string; | ||||||||||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * icon size | ||||||||||||||||||||||
| * @default 20 | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| iconSize?: number; | ||||||||||||||||||||||
|
Comment on lines
+99
to
+103
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. JSDoc의 JSDoc에서 📝 수정 제안 /**
* icon size
- * `@default` 20
+ * `@default` 13.5
*/
iconSize?: number;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * icon vertical alignment position. | ||||||||||||||||||||||
| * @default 'center' | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| iconAlign?: 'start' | 'center' | 'end'; | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const ACCORDION_MOTION = { | ||||||||||||||||||||||
|
|
@@ -95,6 +118,12 @@ const ACCORDION_MOTION = { | |||||||||||||||||||||
| }, | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const ALIGN_ICON = { | ||||||||||||||||||||||
| start: 'self-start', | ||||||||||||||||||||||
| center: 'self-center', | ||||||||||||||||||||||
| end: 'self-end', | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const isInteractiveElement = (element: HTMLElement) => { | ||||||||||||||||||||||
| const INTERACTIVE_TAGS = ['INPUT', 'TEXTAREA', 'A']; | ||||||||||||||||||||||
| return INTERACTIVE_TAGS.includes(element.tagName); | ||||||||||||||||||||||
|
|
@@ -106,10 +135,16 @@ export function AccordionItem({ | |||||||||||||||||||||
| value, | ||||||||||||||||||||||
| btnClassName, | ||||||||||||||||||||||
| contentClassName, | ||||||||||||||||||||||
| iconWrapperClassName, | ||||||||||||||||||||||
| iconClassName, | ||||||||||||||||||||||
| iconSize, | ||||||||||||||||||||||
| iconAlign = 'center', | ||||||||||||||||||||||
| children, | ||||||||||||||||||||||
| ...props | ||||||||||||||||||||||
| }: AccordionItemProps) { | ||||||||||||||||||||||
| const context = useAccordion(); | ||||||||||||||||||||||
| const rawIconSize = iconSize ?? context.iconSize ?? 13.5; | ||||||||||||||||||||||
| const normalizedIconSize = Number.isFinite(rawIconSize) && rawIconSize > 0 ? rawIconSize : 13.5; | ||||||||||||||||||||||
| const uid = useId(); | ||||||||||||||||||||||
| const triggerId = `accordion-trigger-${uid}`; | ||||||||||||||||||||||
| const contentId = `accordion-content-${uid}`; | ||||||||||||||||||||||
|
|
@@ -145,9 +180,9 @@ export function AccordionItem({ | |||||||||||||||||||||
| <motion.div | ||||||||||||||||||||||
| animate={{ rotate: isOpen ? 180 : 0 }} | ||||||||||||||||||||||
| transition={{ duration: 0.2 }} | ||||||||||||||||||||||
| className="ml-2" | ||||||||||||||||||||||
| className={cn('ml-2', ALIGN_ICON[iconAlign], iconWrapperClassName)} | ||||||||||||||||||||||
| > | ||||||||||||||||||||||
| <Icon name="arrowDown" size={20} /> | ||||||||||||||||||||||
| <Icon name="arrowDown" size={normalizedIconSize} className={iconClassName} /> | ||||||||||||||||||||||
| </motion.div> | ||||||||||||||||||||||
| )} | ||||||||||||||||||||||
| </div> | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
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.
iconsize를 컨트롤할수있는 속성이 있음 좋을 것 같네용
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.
510e296 수정완료입니당