Skip to content

Commit

Permalink
feat(Form dialog): add icon left to primary button (#3730)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddouglasz authored Feb 26, 2025
1 parent 1ab4a04 commit b05672c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/lovely-donuts-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@commercetools-frontend/application-components': minor
---

Pass a new prop `iconLeftPrimaryButton`, to provide an icon to the left in the primary button of the form dialog.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ describe('rendering', () => {
},
}));

it('should show primaryButton Icon', () =>
validateComponent({
title: 'Lorem ipsus',
extraProps: {
iconLeftPrimaryButton: <div>button icon</div>,
},
extraChecks: () => {
screen.getByText('button icon');
},
}));

it('should show additional content in footer', () =>
validateComponent({
title: 'Lorem ipsus',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type TFormDialogProps = {
dataAttributesPrimaryButton?: { [key: string]: string };
getParentSelector?: () => HTMLElement;
iconLeftSecondaryButton?: ReactElement;
iconLeftPrimaryButton?: ReactElement;
footerContent?: ReactNode;
};

Expand Down Expand Up @@ -59,6 +60,7 @@ const FormDialog = ({
dataAttributesSecondaryButton={props.dataAttributesSecondaryButton}
dataAttributesPrimaryButton={props.dataAttributesPrimaryButton}
iconLeftSecondaryButton={props.iconLeftSecondaryButton}
iconLeftPrimaryButton={props.iconLeftPrimaryButton}
footerContent={props.footerContent}
/>
</DialogContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Props = {
dataAttributesSecondaryButton?: { [key: string]: string };
children?: never;
iconLeftSecondaryButton?: ReactElement;
iconLeftPrimaryButton?: ReactElement;
footerContent?: ReactNode;
};

Expand Down Expand Up @@ -60,6 +61,7 @@ const DialogFooter = ({
/>
<PrimaryButton
label={getFormattedLabel(props.labelPrimary, intl)}
iconLeft={props.iconLeftPrimaryButton}
onClick={props.onConfirm}
isDisabled={isPrimaryButtonDisabled}
{...filterDataAttributes(dataAttributesPrimaryButton)}
Expand Down

0 comments on commit b05672c

Please sign in to comment.