Skip to content

Commit

Permalink
feat(form dialog): update prop name
Browse files Browse the repository at this point in the history
  • Loading branch information
Ddouglasz committed Aug 8, 2024
1 parent 46f7427 commit e5dce4a
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .changeset/nasty-dragons-grin.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
'@commercetools-frontend/application-components': minor
---

Add a new property `leftAlignedFooterContent`to the form dialog. This provides an additional content positioned to the left area of the form dialog footer.
Add a new property `footerContent`to the form dialog. This provides an additional content positioned to the left area of the form dialog footer.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('rendering', () => {
validateComponent({
title: 'Lorem ipsus',
extraProps: {
leftAlignedFooterContent: <a href="/#">Left aligned content</a>,
footerContent: <a href="/#">Left aligned content</a>,
},
extraChecks: () => {
screen.getByText('Left aligned content');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export type TFormDialogProps = {
dataAttributesPrimaryButton?: { [key: string]: string };
getParentSelector?: () => HTMLElement;
iconLeftSecondaryButton?: ReactElement;
leftAlignedFooterContent?: ReactNode;
footerContent?: ReactNode;
};
const defaultProps: Pick<TFormDialogProps, 'labelSecondary' | 'labelPrimary'> =
{
Expand Down Expand Up @@ -60,7 +60,7 @@ const FormDialog = (props: TFormDialogProps) => (
dataAttributesSecondaryButton={props.dataAttributesSecondaryButton}
dataAttributesPrimaryButton={props.dataAttributesPrimaryButton}
iconLeftSecondaryButton={props.iconLeftSecondaryButton}
leftAlignedFooterContent={props.leftAlignedFooterContent}
footerContent={props.footerContent}
/>
</DialogContainer>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type Props = {
dataAttributesSecondaryButton: { [key: string]: string };
children?: never;
iconLeftSecondaryButton?: ReactElement;
leftAlignedFooterContent?: ReactNode;
footerContent?: ReactNode;
};
const defaultProps: Pick<
Props,
Expand All @@ -51,39 +51,31 @@ const DialogFooter = (props: Props) => {
`}
>
<Spacings.Inline alignItems="center" justifyContent="space-between">
{props.leftAlignedFooterContent && (
<Spacings.Inline
scale="m"
alignItems="center"
justifyContent="flex-start"
>
{props.leftAlignedFooterContent}
</Spacings.Inline>
)}
<div
css={css`
margin-left: auto;
`}
<Spacings.Inline
scale="m"
alignItems="center"
justifyContent="flex-start"
>
<Spacings.Inline
scale="m"
alignItems="center"
justifyContent="flex-end"
>
<SecondaryButton
label={getFormattedLabel(props.labelSecondary, intl)}
onClick={props.onCancel}
iconLeft={props.iconLeftSecondaryButton}
{...filterDataAttributes(props.dataAttributesSecondaryButton)}
/>
<PrimaryButton
label={getFormattedLabel(props.labelPrimary, intl)}
onClick={props.onConfirm}
isDisabled={props.isPrimaryButtonDisabled}
{...filterDataAttributes(props.dataAttributesPrimaryButton)}
/>
</Spacings.Inline>
</div>
<div>{props.footerContent}</div>
</Spacings.Inline>
<Spacings.Inline
scale="m"
alignItems="center"
justifyContent="flex-end"
>
<SecondaryButton
label={getFormattedLabel(props.labelSecondary, intl)}
onClick={props.onCancel}
iconLeft={props.iconLeftSecondaryButton}
{...filterDataAttributes(props.dataAttributesSecondaryButton)}
/>
<PrimaryButton
label={getFormattedLabel(props.labelPrimary, intl)}
onClick={props.onConfirm}
isDisabled={props.isPrimaryButtonDisabled}
{...filterDataAttributes(props.dataAttributesPrimaryButton)}
/>
</Spacings.Inline>
</Spacings.Inline>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const FormDialogExample = (props: ContainerProps) => (
document.querySelector(`#${props.portalId}`) as HTMLElement
}
zIndex={10001}
leftAlignedFooterContent={props.leftAlignedFooterContent}
footerContent={props.footerContent}
>
<Spacings.Stack scale="m">
<TextField
Expand Down Expand Up @@ -111,14 +111,14 @@ export const Component = () => (
/>
</Spec>
<Spec
label="FormDialog - leftAlignedFooterContent provided"
label="FormDialog - footerContent provided"
size="l"
contentAlignment="center"
>
<FormDialogExample
size="l"
portalId="dialog-left-aligned-footer-content"
leftAlignedFooterContent={<a href="/#">lorem ipsum</a>}
footerContent={<a href="/#">lorem ipsum</a>}
/>
</Spec>
</Suite>
Expand Down
4 changes: 1 addition & 3 deletions website-components-playground/src/pages/form-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ const FormDialogExample = () => (
event as FormEvent<HTMLFormElement>
)
}
leftAlignedFooterContent={
<a href="/#">Left aligned content</a>
}
footerContent={<a href="/#">Left aligned content</a>}
>
<Spacings.Stack scale="m">
<TextField
Expand Down

0 comments on commit e5dce4a

Please sign in to comment.