Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FooterHelp] Add align property #11764

Merged
merged 3 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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({
'--pc-footer-help-align': 'start',
}) as React.CSSProperties,
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ examples:
- fileName: footer-help-default.tsx
title: Default
description: Use to direct merchants to more information related to the product or feature they’re working on.
- fileName: footer-help-align.tsx
title: Align
description: Control the horizontal alignment of component using the align prop.
previewImg: /images/components/navigation/footer-help.png
---

Expand Down
30 changes: 30 additions & 0 deletions polaris.shopify.com/pages/examples/footer-help-align.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {BlockStack, FooterHelp, Link} from '@shopify/polaris';
import React from 'react';
import {withPolarisExample} from '../../src/components/PolarisExampleWrapper';

function FooterHelpAlignExample() {
return (
<BlockStack gap="1600">
<FooterHelp align="start">
Start{' '}
<Link url="https://help.shopify.com/manual/orders/fulfill-orders">
fulfilling orders
</Link>
</FooterHelp>
<FooterHelp align="center">
Center{' '}
<Link url="https://help.shopify.com/manual/orders/fulfill-orders">
fulfilling orders
</Link>
</FooterHelp>
<FooterHelp align="end">
End{' '}
<Link url="https://help.shopify.com/manual/orders/fulfill-orders">
fulfilling orders
</Link>
</FooterHelp>
</BlockStack>
);
}

export default withPolarisExample(FooterHelpAlignExample);
Loading