Skip to content

Commit

Permalink
Optional iconProps can be passed to Accordions (#1794)
Browse files Browse the repository at this point in the history
<!--
Hello 👋 Thank you for submitting a pull request.

To help us merge your PR, make sure to follow the instructions below:

- Create or update the tests
- Create or update the documentation at
https://github.com/strapi/documentation
- Refer to the issue you are closing in the PR description: Fix #issue
- Specify if the PR is ready to be merged or work in progress (by
opening a draft PR)

Please ensure you read the Contributing Guide:
https://github.com/strapi/strapi/blob/master/CONTRIBUTING.md
-->

### What does it do?

Adds an optional prop 'iconProps' to the Accordion component

### Why is it needed?

So we can modify the icon, e.g. add a fill color to it

This came up when converting the SEO plugin to v5 through
strapi/strapi-plugin-seo#76


### Related issue(s)/PR(s)

DX-1693
  • Loading branch information
jhoward1994 authored Oct 9, 2024
2 parents 9633f19 + 8bd760b commit 0bdddfb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
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

0 comments on commit 0bdddfb

Please sign in to comment.