Skip to content

Commit

Permalink
[EmptyState] Consolidate se23 logic and styles (#10009)
Browse files Browse the repository at this point in the history
### WHY are these changes introduced?

Fixes #9933

### WHAT is this pull request doing?

Consolidates se23 beta styles for `EmptyState`.

### How to 🎩

Compare and make sure they are the same:

* This PR's
[Storybook](https://5d559397bae39100201eedc1-xyztablchw.chromatic.com/?path=/story/all-components-emptystate--default)
* [Production
Storybook](https://storybook.polaris.shopify.com/?path=/story/all-components-emptystate--default&globals=polarisSummerEditions2023:true)
  • Loading branch information
sophschneider authored and sam-b-rose committed Aug 15, 2023
1 parent 3d143b6 commit de5d297
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .changeset/tall-chicken-repeat.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
'@shopify/polaris': major
---

Removed Summer Editions experimental styles and code for the following components: `Avatar`, `AccountConnection`, `ActionList`, `ActionMenu`, `Autocomplete`, `Breadcrumbs`, `Text`, `KeyboardKey`
Removed Summer Editions experimental styles and code for the following components: `Avatar`, `AccountConnection`, `ActionList`, `ActionMenu`, `Autocomplete`, `Breadcrumbs`, `Text`, `KeyboardKey`, `EmptyState`
32 changes: 6 additions & 26 deletions polaris-react/src/components/EmptyState/EmptyState.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import React, {useContext} from 'react';
import React from 'react';

import {classNames} from '../../utilities/css';
import {WithinContentContext} from '../../utilities/within-content-context';
import type {ComplexAction} from '../../types';
import {Box} from '../Box';
import {buttonFrom} from '../Button';
import {Image} from '../Image';
import {Text} from '../Text';
import {VerticalStack} from '../VerticalStack';
import {HorizontalStack} from '../HorizontalStack';
import {useFeatures} from '../../utilities/features';

import styles from './EmptyState.scss';

Expand Down Expand Up @@ -48,8 +46,6 @@ export function EmptyState({
secondaryAction,
footerContent,
}: EmptyStateProps) {
const {polarisSummerEditions2023} = useFeatures();
const withinContentContainer = useContext(WithinContentContext);
const imageContainedClass = classNames(
imageContained && styles.imageContained,
);
Expand Down Expand Up @@ -81,49 +77,33 @@ export function EmptyState({

const footerContentMarkup = footerContent ? (
<Box paddingBlockStart="4">
<Text
as="span"
color={polarisSummerEditions2023 ? undefined : 'subdued'}
alignment="center"
variant={polarisSummerEditions2023 ? 'bodySm' : 'bodyMd'}
>
<Text as="span" alignment="center" variant="bodySm">
{footerContent}
</Text>
</Box>
) : null;

const headingSize = withinContentContainer ? 'headingLg' : 'headingXl';

const primaryActionMarkup = action
? buttonFrom(action, {primary: true, size: 'medium'})
: null;

const headingMarkup = heading ? (
<Box paddingBlockEnd={polarisSummerEditions2023 ? '1_5-experimental' : '4'}>
<Text
variant={polarisSummerEditions2023 ? 'headingMd' : headingSize}
as="p"
alignment="center"
>
<Box paddingBlockEnd="1_5-experimental">
<Text variant="headingMd" as="p" alignment="center">
{heading}
</Text>
</Box>
) : null;

const childrenMarkup = children ? (
<Text
as="span"
color={polarisSummerEditions2023 ? undefined : 'subdued'}
alignment="center"
variant={polarisSummerEditions2023 ? 'bodySm' : 'bodyMd'}
>
<Text as="span" alignment="center" variant="bodySm">
{children}
</Text>
) : null;

const textContentMarkup =
headingMarkup || children ? (
<Box paddingBlockEnd={polarisSummerEditions2023 ? '4' : '6'}>
<Box paddingBlockEnd="4">
{headingMarkup}
{childrenMarkup}
</Box>
Expand Down

0 comments on commit de5d297

Please sign in to comment.