Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7b0847f
remove max-width from AlphaStack
yurm04 Nov 29, 2022
e20127b
replaced with layout components
yurm04 Nov 29, 2022
513db9c
add responsive to maxwidth on Box
yurm04 Nov 29, 2022
f6f11ac
[ResourceItem] Use layout components (#7784)
kyledurand Nov 30, 2022
ad0d867
updated responsive props
yurm04 Nov 30, 2022
1c32286
add getResponsiveValues
yurm04 Nov 30, 2022
5cf6e15
revert story and remove padding on actions
yurm04 Nov 30, 2022
421082a
Merge branch 'main' into layout-rebuild-batch-2
aveline Dec 1, 2022
6e6d97f
[Layout] Update `ActionList` to use Layout primitives (#7805)
aveline Dec 1, 2022
9498d87
remove responsive max width
yurm04 Dec 1, 2022
b8620d8
remove support for responsive values in max width Box
yurm04 Dec 1, 2022
a30abce
remove all other styles
yurm04 Dec 1, 2022
8a02260
add class to image
yurm04 Dec 2, 2022
f771e3e
fix test
yurm04 Dec 2, 2022
49f5763
[ResourceItem] Use layout components (#7784)
kyledurand Nov 30, 2022
08a5d05
[Layout] Update `ActionList` to use Layout primitives (#7805)
aveline Dec 1, 2022
3d8fc97
Merge branch 'layout-rebuild-batch-2' of https://github.com/Shopify/p…
aveline Dec 2, 2022
61b4223
Merge branch 'layout-rebuild-batch-2' of https://github.com/Shopify/p…
yurm04 Dec 2, 2022
d2ff651
[polaris.shopify.com] Run `get-props` script
laurkim Dec 2, 2022
fc21b67
Merge branch 'layout-rebuild-batch-2' of https://github.com/Shopify/p…
yurm04 Dec 2, 2022
4afece0
[SkeletonPage] Rebuild with layout primitives (#7797)
chazdean Dec 2, 2022
ea0150a
remove stack from tests
yurm04 Dec 2, 2022
4236de6
apply withinContentContainer styling
yurm04 Dec 2, 2022
c1c982b
add delay to story
yurm04 Dec 5, 2022
20dfd92
remove Boxes with no styling
yurm04 Dec 5, 2022
527f8db
revert alphastack
yurm04 Dec 5, 2022
40b8ea5
reset alphastack
yurm04 Dec 5, 2022
f1f1287
reset alphastack
yurm04 Dec 5, 2022
97a9798
Merge https://github.com/Shopify/polaris into layout-rebuild-batch-2
yurm04 Dec 6, 2022
2c1ae18
Merge branch 'layout-rebuild-batch-2' in
yurm04 Dec 6, 2022
2660d00
uped chromatic delay
yurm04 Dec 6, 2022
efbe25d
uped chromatic
yurm04 Dec 6, 2022
5530643
uped chromatic
yurm04 Dec 6, 2022
0a486f3
Merge branch 'layout-rebuild-batch-2' into rebuilt-empty-state
yurm04 Jan 10, 2023
cde834b
revert to current state
yurm04 Jan 10, 2023
d3d623d
remove chromatic delay
yurm04 Jan 10, 2023
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
154 changes: 3 additions & 151 deletions polaris-react/src/components/EmptyState/EmptyState.scss
Original file line number Diff line number Diff line change
@@ -1,156 +1,8 @@
@import '../../styles/common';

$within-page-detail-width: 336px;
$detail-width: 400px;

$stacking-order: (
illustration: 0,
details: 10,
);

$left-offset: 35%;
$right-offset: 10%;

// Multiply by 2 to expand the image size to align with design requirements
$illustration-left-margin: $left-offset * -2;

// Shift the illustration to the left to overlap with Details
$illustration-width: calc(100% + #{$left-offset} * 2);

// Respect the right offset on mobile so the illustration shows the correct
// crop zone
$illustration-width-cropped: calc(
#{$illustration-width} + #{$right-offset} * 2
);

$centered-illustration-width: 226px;

.EmptyState {
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
display: flex;
flex-direction: column;
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
align-items: center;
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
width: 100%;
margin: 0 auto;
padding: var(--p-space-5) 0;
padding-top: var(--p-space-5);
padding-bottom: calc(3 * var(--p-space-5));
max-width: $page-max-width;
}

.Section {
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
display: flex;
flex-direction: column-reverse;
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
flex: 1 1 auto;
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
width: 100%;
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
align-items: center;
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
justify-content: center;

@media #{$p-breakpoints-md-up} {
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
left: var(--p-space-5);
}
}

.Details {
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
display: flex;
text-align: center;
flex-direction: column;
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
align-items: center;

@media #{$p-breakpoints-sm-up} {
max-width: $detail-width;
}
}

.Image {
margin: 0;
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
width: initial;
}

.ImageContainer,
.DetailsContainer {
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
flex: 1 1 auto;
padding: 0;
margin: 0;

@media #{$p-breakpoints-md-up} {
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
flex-basis: 50%;
}
}

.withinContentContainer {
margin: 0 auto;
padding-top: var(--p-space-5);
padding-bottom: calc(3 * var(--p-space-5));

.Section {
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
position: unset;
flex-direction: column-reverse;
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
align-items: center;
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
justify-content: center;
}

.Details {
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
display: flex;
text-align: center;
flex-direction: column;
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
align-items: center;

@media #{$p-breakpoints-sm-up} {
max-width: $detail-width;
}
}

.Image {
margin: 0;
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
width: initial;
}

.Content {
padding-bottom: var(--p-space-2);
}
}

.imageContained {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

had to keep this class because we don't do responsive props in Image

.Image {
@media #{$p-breakpoints-md-up} {
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
position: initial;
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
width: 100%;
}
}
}

.fullWidth {
.Details {
max-width: 100%;
@media #{$p-breakpoints-md-up} {
position: initial;
width: 100%;
}
}

.Content {
padding-bottom: var(--p-space-2);
}

.Actions {
margin-top: var(--p-space-4);
}
16 changes: 16 additions & 0 deletions polaris-react/src/components/EmptyState/EmptyState.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,19 @@ export function WithFullWidthLayout() {
</Card>
);
}

export function WithoutContentContainer() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added this story for any cases when an empty state component is not wrapped in a content container

return (
<EmptyState
heading="Manage your inventory transfers"
action={{content: 'Add transfer'}}
secondaryAction={{
content: 'Learn more',
url: 'https://help.shopify.com',
}}
image="https://cdn.shopify.com/s/files/1/0262/4071/2726/files/emptystate-files.png"
>
<p>Track and receive your incoming inventory from suppliers.</p>
</EmptyState>
);
}
77 changes: 40 additions & 37 deletions polaris-react/src/components/EmptyState/EmptyState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import type {ComplexAction} from '../../types';
import {Box} from '../Box';
import {buttonFrom} from '../Button';
import {Image} from '../Image';
import {Stack} from '../Stack';
import {TextContainer} from '../TextContainer';
import {Text} from '../Text';
import {AlphaStack} from '../AlphaStack';
import {Inline} from '../Inline';

import styles from './EmptyState.scss';

Expand Down Expand Up @@ -48,27 +48,29 @@ export function EmptyState({
footerContent,
}: EmptyStateProps) {
const withinContentContainer = useContext(WithinContentContext);
const className = classNames(
styles.EmptyState,
fullWidth && styles.fullWidth,
const imageContainedClass = classNames(
imageContained && styles.imageContained,
withinContentContainer && styles.withinContentContainer,
);

const imageMarkup = largeImage ? (
<Image
alt=""
role="presentation"
className={styles.Image}
source={largeImage}
className={imageContainedClass}
sourceSet={[
{source: image, descriptor: '568w'},
{source: largeImage, descriptor: '1136w'},
]}
sizes="(max-width: 568px) 60vw"
/>
) : (
<Image role="presentation" alt="" className={styles.Image} source={image} />
<Image
className={imageContainedClass}
role="presentation"
alt=""
source={image}
/>
);

const secondaryActionMarkup = secondaryAction
Expand All @@ -77,7 +79,7 @@ export function EmptyState({

const footerContentMarkup = footerContent ? (
<Box paddingBlockStart="4">
<Text as="span" variant="bodyMd" color="subdued">
<Text as="span" variant="bodyMd" color="subdued" alignment="center">
{footerContent}
</Text>
</Box>
Expand All @@ -90,56 +92,57 @@ export function EmptyState({
: null;

const headingMarkup = heading ? (
<Text variant={headingSize} as="p">
{heading}
</Text>
<Box paddingBlockEnd="4">
<Text variant={headingSize} as="p" alignment="center">
{heading}
</Text>
</Box>
) : null;

const childrenMarkup = children ? (
<div className={styles.Content}>
<Text as="span" variant="bodyMd" color="subdued">
{children}
</Text>
</div>
<Text as="span" variant="bodyMd" color="subdued" alignment="center">
{children}
</Text>
) : null;

const textContentMarkup =
headingMarkup || children ? (
<TextContainer>
<Box paddingBlockEnd="6">
{headingMarkup}
{childrenMarkup}
</TextContainer>
</Box>
) : null;

const actionsMarkup =
primaryActionMarkup || secondaryActionMarkup ? (
<div className={styles.Actions}>
<Stack alignment="center" distribution="center" spacing="tight">
{secondaryActionMarkup}
{primaryActionMarkup}
</Stack>
</div>
<Inline align="center" gap="2">
{secondaryActionMarkup}
{primaryActionMarkup}
</Inline>
) : null;

const detailsMarkup =
textContentMarkup || actionsMarkup || footerContentMarkup ? (
<div className={styles.DetailsContainer}>
<div className={styles.Details}>
<Box maxWidth={fullWidth ? '100%' : '400px'}>
<AlphaStack align="center" gap="0">
{textContentMarkup}
{actionsMarkup}
{footerContentMarkup}
</div>
</div>
) : (
<div className={styles.DetailsContainer} />
);
</AlphaStack>
</Box>
) : null;

return (
<div className={className}>
<div className={styles.Section}>
<Box
paddingInlineStart="0"
paddingInlineEnd="0"
paddingBlockStart="5"
paddingBlockEnd="16"
>
<AlphaStack align="center" gap="0" reverseOrder={withinContentContainer}>
{detailsMarkup}
<div className={styles.ImageContainer}>{imageMarkup}</div>
</div>
</div>
{imageMarkup}
</AlphaStack>
</Box>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import {mountWithApp} from 'tests/utilities';

import {Button} from '../../Button';
import {Image} from '../../Image';
import {Stack} from '../../Stack';
import {Text} from '../../Text';
import {UnstyledLink} from '../../UnstyledLink';
import {WithinContentContext} from '../../../utilities/within-content-context';
import {EmptyState} from '../EmptyState';
import {Inline} from '../../Inline';

describe('<EmptyState />', () => {
let imgSrc =
Expand Down Expand Up @@ -50,14 +50,14 @@ describe('<EmptyState />', () => {
});
});

it('adds center distribution and tight spacing to Stack', () => {
it('adds center align and spacing-2 to Inline', () => {
const emptyState = mountWithApp(
<EmptyState image={imgSrc} action={{content: 'Add transfer'}} />,
);

expect(emptyState).toContainReactComponent(Stack, {
spacing: 'tight',
distribution: 'center',
expect(emptyState).toContainReactComponent(Inline, {
align: 'center',
gap: '2',
});
});

Expand Down