Skip to content

Commit

Permalink
feat(accordion): added string child handling
Browse files Browse the repository at this point in the history
  • Loading branch information
hirotomoyamada committed Nov 10, 2023
1 parent 09c791c commit 100866f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 131 deletions.
5 changes: 5 additions & 0 deletions .changeset/three-windows-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@yamada-ui/accordion': minor
---

Added string child handling and rendering.
8 changes: 7 additions & 1 deletion packages/components/accordion/src/accordion-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ export const AccordionPanel = forwardRef<AccordionPanelProps, 'div'>(
transitionEnd,
delay,
duration,
children,
...rest
},
ref,
) => {
const { isOpen, getPanelProps } = useAccordionItemContext()
const { styles } = useAccordionContext()

const resolvedChildren =
typeof children === 'string' ? <p>{children}</p> : children

const css: CSSUIObject = { ...styles.panel }

return (
Expand All @@ -50,7 +54,9 @@ export const AccordionPanel = forwardRef<AccordionPanelProps, 'div'>(
{...getPanelProps(rest, ref)}
className={cx('ui-accordion__panel', className)}
__css={css}
/>
>
{resolvedChildren}
</ui.div>
</Collapse>
)
},
Expand Down
Loading

0 comments on commit 100866f

Please sign in to comment.