Skip to content

Commit b05672c

Browse files
authored
feat(Form dialog): add icon left to primary button (#3730)
1 parent 1ab4a04 commit b05672c

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

.changeset/lovely-donuts-mate.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@commercetools-frontend/application-components': minor
3+
---
4+
5+
Pass a new prop `iconLeftPrimaryButton`, to provide an icon to the left in the primary button of the form dialog.

packages/application-components/src/components/dialogs/form-dialog/form-dialog.spec.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ describe('rendering', () => {
5454
},
5555
}));
5656

57+
it('should show primaryButton Icon', () =>
58+
validateComponent({
59+
title: 'Lorem ipsus',
60+
extraProps: {
61+
iconLeftPrimaryButton: <div>button icon</div>,
62+
},
63+
extraChecks: () => {
64+
screen.getByText('button icon');
65+
},
66+
}));
67+
5768
it('should show additional content in footer', () =>
5869
validateComponent({
5970
title: 'Lorem ipsus',

packages/application-components/src/components/dialogs/form-dialog/form-dialog.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export type TFormDialogProps = {
3131
dataAttributesPrimaryButton?: { [key: string]: string };
3232
getParentSelector?: () => HTMLElement;
3333
iconLeftSecondaryButton?: ReactElement;
34+
iconLeftPrimaryButton?: ReactElement;
3435
footerContent?: ReactNode;
3536
};
3637

@@ -59,6 +60,7 @@ const FormDialog = ({
5960
dataAttributesSecondaryButton={props.dataAttributesSecondaryButton}
6061
dataAttributesPrimaryButton={props.dataAttributesPrimaryButton}
6162
iconLeftSecondaryButton={props.iconLeftSecondaryButton}
63+
iconLeftPrimaryButton={props.iconLeftPrimaryButton}
6264
footerContent={props.footerContent}
6365
/>
6466
</DialogContainer>

packages/application-components/src/components/dialogs/internals/dialog-footer.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type Props = {
2626
dataAttributesSecondaryButton?: { [key: string]: string };
2727
children?: never;
2828
iconLeftSecondaryButton?: ReactElement;
29+
iconLeftPrimaryButton?: ReactElement;
2930
footerContent?: ReactNode;
3031
};
3132

@@ -60,6 +61,7 @@ const DialogFooter = ({
6061
/>
6162
<PrimaryButton
6263
label={getFormattedLabel(props.labelPrimary, intl)}
64+
iconLeft={props.iconLeftPrimaryButton}
6365
onClick={props.onConfirm}
6466
isDisabled={isPrimaryButtonDisabled}
6567
{...filterDataAttributes(dataAttributesPrimaryButton)}

0 commit comments

Comments
 (0)