Skip to content

Commit 631f941

Browse files
committed
Refactor Placeholder component
1 parent 569c1c8 commit 631f941

File tree

8 files changed

+39
-41
lines changed

8 files changed

+39
-41
lines changed

.changeset/heavy-eagles-train.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
'polaris.shopify.com': patch
33
---
44

5-
Update `AlphaStack` component docs
5+
Update `AlphaStack` component docs and added `ExampleStyleGuideComponents` for layout primitives

polaris.shopify.com/pages/examples/ExampleStyleGuideComponents/AlignBlockComponent/Placeholder.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface PlaceholderProps {
1010
childAlign?: Align;
1111
}
1212

13-
export const Placeholder = ({
13+
const Placeholder = ({
1414
label,
1515
height,
1616
width,
@@ -20,9 +20,9 @@ export const Placeholder = ({
2020
<div
2121
style={{
2222
background: 'var(--surface-example-block)',
23-
padding: '14px 8px 14px 8px',
24-
height: height ? `${height}px` : '',
25-
width: width ? `${width}px` : '',
23+
padding: '14px var(--p-space-2)',
24+
height: height ?? undefined,
25+
width: width ?? undefined,
2626
}}
2727
>
2828
<Inline align={childAlign}>
@@ -41,3 +41,5 @@ export const Placeholder = ({
4141
</div>
4242
);
4343
};
44+
45+
export default Placeholder;

polaris.shopify.com/pages/examples/ExampleStyleGuideComponents/DefaultBlockComponent/Placeholder.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,22 @@ export interface PlaceholderProps {
88
childWidth?: string;
99
}
1010

11-
export const Placeholder = ({
12-
label,
13-
height,
14-
width,
15-
childWidth,
16-
}: PlaceholderProps) => {
11+
const Placeholder = ({label, height, width, childWidth}: PlaceholderProps) => {
1712
return (
1813
<div
1914
style={{
2015
background: 'var(--surface-example-block)',
21-
padding: '14px 8px 14px 8px',
22-
height: height ? `${height}px` : '',
23-
width: width ? `${width}px` : '',
16+
padding: '14px var(--p-space-2)',
17+
height: height ?? undefined,
18+
width: width ?? undefined,
2419
}}
2520
>
2621
<div
2722
style={{
2823
display: 'inline-block',
2924
background: 'rgba(255, 255, 255, 0.3)',
3025
color: '#FFFFFF',
31-
width: childWidth ? `${childWidth}` : '',
26+
width: childWidth ?? undefined,
3227
}}
3328
>
3429
<Text as="h2" variant="bodyMd" fontWeight="medium">
@@ -38,3 +33,5 @@ export const Placeholder = ({
3833
</div>
3934
);
4035
};
36+
37+
export default Placeholder;

polaris.shopify.com/pages/examples/ExampleStyleGuideComponents/SpacingBackgroundExample.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@ export interface SpacingBackgroundProps {
55
width?: string;
66
}
77

8-
export const SpacingBackground = ({
9-
children,
10-
width,
11-
}: SpacingBackgroundProps) => {
8+
const SpacingBackground = ({children, width}: SpacingBackgroundProps) => {
129
return (
1310
<div
1411
style={{
1512
background:
1613
'repeating-linear-gradient(-45deg, #7B47F1, #7B47F1 1px, #E8D1FA 1px, #E8D1FA 7px)',
17-
width: width ? `${width}px` : '100%',
14+
width: width ?? '100%',
1815
height: 'auto',
1916
}}
2017
>
2118
{children}
2219
</div>
2320
);
2421
};
22+
23+
export default SpacingBackground;

polaris.shopify.com/pages/examples/alpha-stack-default.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import React from 'react';
22
import {AlphaStack} from '@shopify/polaris';
3-
import {Placeholder} from './ExampleStyleGuideComponents/DefaultBlockComponent/Placeholder';
3+
import Placeholder from './ExampleStyleGuideComponents/DefaultBlockComponent/Placeholder';
44

55
import {withPolarisExample} from '../../src/components/PolarisExampleWrapper';
66

77
function AlphaStackExample() {
88
return (
99
<AlphaStack>
10-
<Placeholder width="320" label="Stack child" />
11-
<Placeholder width="320" />
12-
<Placeholder width="320" />
10+
<Placeholder width="320px" label="Stack child" />
11+
<Placeholder width="320px" />
12+
<Placeholder width="320px" />
1313
</AlphaStack>
1414
);
1515
}

polaris.shopify.com/pages/examples/alpha-stack-with-align.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import {AlphaStack, Box, Page, Inline} from '@shopify/polaris';
3-
import {Placeholder} from './ExampleStyleGuideComponents/AlignBlockComponent/Placeholder';
3+
import Placeholder from './ExampleStyleGuideComponents/AlignBlockComponent/Placeholder';
44

55
import {withPolarisExample} from '../../src/components/PolarisExampleWrapper';
66

@@ -9,25 +9,25 @@ function AlphaStackWithAlignExample() {
99
<Page>
1010
<Box paddingBottom="20">
1111
<AlphaStack align="start">
12-
<Placeholder width="320" label="Start" childAlign="start" />
13-
<Placeholder width="320" />
14-
<Placeholder width="320" />
12+
<Placeholder width="320px" label="Start" childAlign="start" />
13+
<Placeholder width="320px" />
14+
<Placeholder width="320px" />
1515
</AlphaStack>
1616
</Box>
1717
<Box paddingBottom="20">
1818
<AlphaStack align="center">
1919
<AlphaStack>
20-
<Placeholder width="320" label="Center" childAlign="center" />
21-
<Placeholder width="320" />
22-
<Placeholder width="320" />
20+
<Placeholder width="320px" label="Center" childAlign="center" />
21+
<Placeholder width="320px" />
22+
<Placeholder width="320px" />
2323
</AlphaStack>
2424
</AlphaStack>
2525
</Box>
2626
<Box>
2727
<AlphaStack align="end">
28-
<Placeholder width="320" label="End" childAlign="end" />
29-
<Placeholder width="320" />
30-
<Placeholder width="320" />
28+
<Placeholder width="320px" label="End" childAlign="end" />
29+
<Placeholder width="320px" />
30+
<Placeholder width="320px" />
3131
</AlphaStack>
3232
</Box>
3333
</Page>

polaris.shopify.com/pages/examples/alpha-stack-with-full-width-children.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import {AlphaStack} from '@shopify/polaris';
3-
import {Placeholder} from './ExampleStyleGuideComponents/DefaultBlockComponent/Placeholder';
3+
import Placeholder from './ExampleStyleGuideComponents/DefaultBlockComponent/Placeholder';
44

55
import {withPolarisExample} from '../../src/components/PolarisExampleWrapper';
66

polaris.shopify.com/pages/examples/alpha-stack-with-spacing.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import React from 'react';
22
import {AlphaStack} from '@shopify/polaris';
3-
import {Placeholder} from './ExampleStyleGuideComponents/DefaultBlockComponent/Placeholder';
4-
import {SpacingBackground} from './ExampleStyleGuideComponents/SpacingBackgroundExample';
3+
import Placeholder from './ExampleStyleGuideComponents/DefaultBlockComponent/Placeholder';
4+
import SpacingBackground from './ExampleStyleGuideComponents/SpacingBackgroundExample';
55

66
import {withPolarisExample} from '../../src/components/PolarisExampleWrapper';
77

88
function AlphaStackWithSpacingExample() {
99
return (
10-
<SpacingBackground width="320">
10+
<SpacingBackground width="320px">
1111
<AlphaStack spacing="5">
12-
<Placeholder width="320" label="Stack child" />
13-
<Placeholder width="320" />
14-
<Placeholder width="320" />
12+
<Placeholder width="320px" label="Stack child" />
13+
<Placeholder width="320px" />
14+
<Placeholder width="320px" />
1515
</AlphaStack>
1616
</SpacingBackground>
1717
);

0 commit comments

Comments
 (0)