Skip to content
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

Optional iconProps can be passed to Accordions #1794

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/stale-apes-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@strapi/design-system': minor
---

pass props to icons in accordion triggers
7 changes: 4 additions & 3 deletions packages/design-system/src/components/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,12 @@ interface TriggerProps extends Omit<RadixAccordion.AccordionTriggerProps, 'asChi
*/
caretPosition?: 'left' | 'right';
description?: string;
icon?: React.ElementType;
icon?: React.ElementType<React.SVGProps<SVGSVGElement>>;
iconProps?: React.SVGProps<SVGSVGElement>;
}

const Trigger = React.forwardRef<TriggerElement, TriggerProps>(
({ caretPosition = 'left', description, icon: Icon, children, ...restProps }, forwardedRef) => {
({ caretPosition = 'left', description, icon: Icon, iconProps, children, ...restProps }, forwardedRef) => {
const { size } = useAccordion('Trigger');

return (
Expand All @@ -138,7 +139,7 @@ const Trigger = React.forwardRef<TriggerElement, TriggerProps>(
<Flex tag="span" gap={2}>
{Icon && size === 'S' ? (
<IconBox>
<Icon />
<Icon {...iconProps} />
</IconBox>
) : null}
<Flex alignItems="flex-start" direction="column" tag="span" ref={forwardedRef}>
Expand Down
Loading