Skip to content

Commit 8ebd378

Browse files
avelinelaurkim
andauthored
Add fullWidth prop for AlphaStack (#7309)
Co-authored-by: Lo Kim <[email protected]>
1 parent 5a7c86b commit 8ebd378

File tree

6 files changed

+58
-4
lines changed

6 files changed

+58
-4
lines changed

.changeset/stale-penguins-love.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@shopify/polaris': minor
3+
'polaris.shopify.com': patch
4+
---
5+
6+
Added `fullWidth` prop to `AlphaStack` and updated styleguide docs

polaris-react/src/components/AlphaStack/AlphaStack.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,9 @@
88
max-width: 100%;
99
}
1010
}
11+
12+
.fullWidth {
13+
> * {
14+
width: 100%;
15+
}
16+
}

polaris-react/src/components/AlphaStack/AlphaStack.stories.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,14 @@ export function AlignEnd() {
4949
</AlphaStack>
5050
);
5151
}
52+
53+
export function FullWidthChildren() {
54+
return (
55+
<AlphaStack fullWidth>
56+
<Badge>Paid</Badge>
57+
<Badge>Processing</Badge>
58+
<Badge>Fulfilled</Badge>
59+
<Badge>Completed</Badge>
60+
</AlphaStack>
61+
);
62+
}

polaris-react/src/components/AlphaStack/AlphaStack.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,24 @@ type Align = 'start' | 'end' | 'center';
1010
export interface AlphaStackProps {
1111
/** Elements to display inside stack */
1212
children?: React.ReactNode;
13-
/** Adjust spacing between elements */
14-
spacing?: SpacingSpaceScale;
1513
/** Adjust vertical alignment of elements */
1614
align?: Align;
15+
/** Toggle elements to be full width */
16+
fullWidth?: boolean;
17+
/** Adjust spacing between elements */
18+
spacing?: SpacingSpaceScale;
1719
}
1820

1921
export const AlphaStack = ({
2022
children,
21-
spacing = '4',
2223
align = 'start',
24+
fullWidth,
25+
spacing = '4',
2326
}: AlphaStackProps) => {
24-
const className = classNames(styles.AlphaStack);
27+
const className = classNames(
28+
styles.AlphaStack,
29+
fullWidth && styles.fullWidth,
30+
);
2531

2632
const style = {
2733
'--pc-stack-align': align ? `${align}` : '',

polaris.shopify.com/content/components/alpha-stack/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ examples:
1818
title: Vertical spacing
1919
description: >-
2020
Vertical spacing for children can be set with the spacing property. Spacing options are provided using our spacing tokens.
21+
- fileName: alpha-stack-with-full-width-children.tsx
22+
title: Full width children
23+
description: >-
24+
Set children to full width
2125
---
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
import {AlphaStack, Badge, Text} from '@shopify/polaris';
3+
4+
import {withPolarisExample} from '../../src/components/PolarisExampleWrapper';
5+
6+
function AlphaStackWithFullWidthChildrenExample() {
7+
return (
8+
<div style={{width: '500px'}}>
9+
<AlphaStack fullWidth>
10+
<Text variant="heading4xl" as="h2">
11+
AlphaStack
12+
</Text>
13+
<Badge>One</Badge>
14+
<Badge>Two</Badge>
15+
<Badge>Three</Badge>
16+
</AlphaStack>
17+
</div>
18+
);
19+
}
20+
21+
export default withPolarisExample(AlphaStackWithFullWidthChildrenExample);

0 commit comments

Comments
 (0)