Skip to content

Commit fc22c21

Browse files
kyledurandjuzser
authored andcommitted
[SkeletonPage] Deprecate breadcrumbs, add backAction, update layout (Shopify#8650)
SkeletonPage breadcrumbs were out of date. This updates the visual design, deprecates the breadcrumbs prop, adds a backAction prop to match with the Page component. Before | After ---|--- ![image](https://screenshot.click/13-57-yni8y-kl0k3.png) | ![image](https://screenshot.click/13-58-3vszj-1q8dc.png)
1 parent e1499af commit fc22c21

File tree

4 files changed

+81
-12
lines changed

4 files changed

+81
-12
lines changed

.changeset/curly-parrots-sit.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris': minor
3+
---
4+
5+
Deprecated breadcrumbs prop on SkeletonPage, added backAction prop with story

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,53 @@ export function WithFullWidth() {
200200
</SkeletonPage>
201201
);
202202
}
203+
204+
export function WithBackAction() {
205+
return (
206+
<SkeletonPage primaryAction backAction>
207+
<Layout>
208+
<Layout.Section>
209+
<LegacyCard sectioned>
210+
<SkeletonBodyText />
211+
</LegacyCard>
212+
<LegacyCard sectioned>
213+
<TextContainer>
214+
<SkeletonDisplayText size="small" />
215+
<SkeletonBodyText />
216+
</TextContainer>
217+
</LegacyCard>
218+
<LegacyCard sectioned>
219+
<TextContainer>
220+
<SkeletonDisplayText size="small" />
221+
<SkeletonBodyText />
222+
</TextContainer>
223+
</LegacyCard>
224+
</Layout.Section>
225+
<Layout.Section secondary>
226+
<LegacyCard>
227+
<LegacyCard.Section>
228+
<TextContainer>
229+
<SkeletonDisplayText size="small" />
230+
<SkeletonBodyText lines={2} />
231+
</TextContainer>
232+
</LegacyCard.Section>
233+
<LegacyCard.Section>
234+
<SkeletonBodyText lines={1} />
235+
</LegacyCard.Section>
236+
</LegacyCard>
237+
<LegacyCard subdued>
238+
<LegacyCard.Section>
239+
<TextContainer>
240+
<SkeletonDisplayText size="small" />
241+
<SkeletonBodyText lines={2} />
242+
</TextContainer>
243+
</LegacyCard.Section>
244+
<LegacyCard.Section>
245+
<SkeletonBodyText lines={2} />
246+
</LegacyCard.Section>
247+
</LegacyCard>
248+
</Layout.Section>
249+
</Layout>
250+
</SkeletonPage>
251+
);
252+
}

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

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
22

33
import {useI18n} from '../../utilities/i18n';
4-
import {SkeletonBodyText} from '../SkeletonBodyText';
54
import {Box} from '../Box';
65
import {Inline} from '../Inline';
76
import {AlphaStack} from '../AlphaStack';
@@ -17,8 +16,10 @@ export interface SkeletonPageProps {
1716
narrowWidth?: boolean;
1817
/** Shows a skeleton over the primary action */
1918
primaryAction?: boolean;
20-
/** Shows a skeleton over the breadcrumb */
19+
/** @deprecated Use backAction instead */
2120
breadcrumbs?: boolean;
21+
/** Shows a skeleton over the backAction */
22+
backAction?: boolean;
2223
/** The child elements to render in the skeleton page. */
2324
children?: React.ReactNode;
2425
}
@@ -29,6 +30,7 @@ export function SkeletonPage({
2930
narrowWidth,
3031
primaryAction,
3132
title = '',
33+
backAction,
3234
breadcrumbs,
3335
}: SkeletonPageProps) {
3436
const i18n = useI18n();
@@ -56,11 +58,16 @@ export function SkeletonPage({
5658
/>
5759
) : null;
5860

59-
const breadcrumbMarkup = breadcrumbs ? (
60-
<Box maxWidth="60px" paddingBlockStart="4" paddingBlockEnd="4">
61-
<SkeletonBodyText lines={1} />
62-
</Box>
63-
) : null;
61+
const breadcrumbMarkup =
62+
breadcrumbs || backAction ? (
63+
<Box
64+
borderRadius="1"
65+
background="surface-neutral"
66+
minHeight="2.25rem"
67+
minWidth="2.25rem"
68+
maxWidth="2.25rem"
69+
/>
70+
) : null;
6471

6572
return (
6673
<AlphaStack gap="4" align="center">
@@ -87,11 +94,13 @@ export function SkeletonPage({
8794
paddingInlineEnd={{xs: '4', sm: '0'}}
8895
width="100%"
8996
>
90-
{breadcrumbMarkup}
9197
<Inline gap="4" align="space-between" blockAlign="center">
92-
<Box paddingBlockStart="1" paddingBlockEnd="1">
93-
{titleContent}
94-
</Box>
98+
<Inline gap="4">
99+
{breadcrumbMarkup}
100+
<Box paddingBlockStart="1" paddingBlockEnd="1">
101+
{titleContent}
102+
</Box>
103+
</Inline>
95104
{primaryActionMarkup}
96105
</Inline>
97106
</Box>

polaris-react/src/components/SkeletonPage/tests/SkeletonPage.test.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ describe('<SkeletonPage />', () => {
6767

6868
it('renders breadcrumbs', () => {
6969
const skeletonPage = mountWithApp(<SkeletonPage breadcrumbs />);
70-
expect(skeletonPage).toContainReactComponent(SkeletonBodyText);
70+
expect(skeletonPage).toContainReactComponent(Box, {
71+
background: 'surface-neutral',
72+
minWidth: '2.25rem',
73+
minHeight: '2.25rem',
74+
maxWidth: '2.25rem',
75+
});
7176
});
7277

7378
describe('primaryAction', () => {

0 commit comments

Comments
 (0)