Skip to content

Commit

Permalink
Add align property for FooterHelp
Browse files Browse the repository at this point in the history
  • Loading branch information
itwasmattgregg committed Mar 20, 2024
1 parent e0ae956 commit 906559c
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/forty-geese-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': minor
---

Added align property for FooterHelp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.FooterHelp {
display: flex;
justify-content: center;
/* stylelint-disable-next-line -- Necessary for layout components */
justify-content: var(--pc-footer-help-align);
margin: var(--p-space-500);
width: auto;
}
Expand Down
26 changes: 24 additions & 2 deletions polaris-react/src/components/FooterHelp/FooterHelp.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react';
import type {ComponentMeta} from '@storybook/react';
import type {Meta} from '@storybook/react';
import {FooterHelp, Link} from '@shopify/polaris';

export default {
component: FooterHelp,
} as ComponentMeta<typeof FooterHelp>;
} as Meta<typeof FooterHelp>;

export function Default() {
return (
Expand All @@ -16,3 +16,25 @@ export function Default() {
</FooterHelp>
);
}

export function LeftAligned() {
return (
<FooterHelp align="start">
Learn more about{' '}
<Link url="https://help.shopify.com/manual/orders/fulfill-orders">
fulfilling orders
</Link>
</FooterHelp>
);
}

export function RightAligned() {
return (
<FooterHelp align="end">
Learn more about{' '}
<Link url="https://help.shopify.com/manual/orders/fulfill-orders">
fulfilling orders
</Link>
</FooterHelp>
);
}
10 changes: 8 additions & 2 deletions polaris-react/src/components/FooterHelp/FooterHelp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ import styles from './FooterHelp.module.css';
export interface FooterHelpProps {
/** The content to display inside the layout. */
children?: React.ReactNode;
/** Horizontal alignment of the component */
align?: 'start' | 'center' | 'end';
}

export function FooterHelp({children}: FooterHelpProps) {
export function FooterHelp({children, align = 'center'}: FooterHelpProps) {
const style = {
'--pc-footer-help-align': align,
} as React.CSSProperties;

return (
<div className={styles.FooterHelp}>
<div className={styles.FooterHelp} style={style}>
<div className={styles.Text}>{children}</div>
</div>
);
Expand Down
12 changes: 12 additions & 0 deletions polaris-react/src/components/FooterHelp/tests/FooterHelp.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,16 @@ describe('<FooterHelp />', () => {
children,
});
});

it('overrides custom properties if they are passed in', () => {
const footerHelp = mountWithApp(
<FooterHelp align="start">{children}</FooterHelp>,
);

expect(footerHelp).toContainReactComponent('div', {
style: expect.objectContaining({
'--p-footer-help-align': 'start',
}) as React.CSSProperties,
});
});
});

0 comments on commit 906559c

Please sign in to comment.