Skip to content

Commit ccdcea2

Browse files
laurkimchazdean
andauthored
[Typography foundations] Text component beta release (#7068)
### WHY are these changes introduced? Resolves #6537, resolves #7647. Deprecates our existing typography components with mapping to the new `Text` component. Updates the `Text` component page in the style guide to use the `beta` flag instead of `alpha`. ### WHAT is this pull request doing? Deprecates `Caption`, `DisplayText`, `Heading`, `Subheading`, `TextStyle`, and `VisuallyHidden` on the style guide and in `polaris-react`. Adds logic in the style guide to hide the prop table if the component is deprecated and hide the component examples if none exist. <details> <summary>Deprecated Caption component page</summary> <img src="https://user-images.githubusercontent.com/26749317/198280661-5b29b45c-9cc9-4bff-aee3-86caf08d65c0.png" alt="Deprecated Caption component page"> </details> <!-- ℹ️ Delete the following for small / trivial changes --> ### How to 🎩 🖥 [Local development instructions](https://github.com/Shopify/polaris/blob/main/README.md#local-development) 🗒 [General tophatting guidelines](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md) 📄 [Changelog guidelines](https://github.com/Shopify/polaris/blob/main/.github/CONTRIBUTING.md#changelog) ### 🎩 checklist - [ ] Tested on [mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing) - [x] Tested on [multiple browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers) - [ ] Tested for [accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md) - [ ] Updated the component's `README.md` with documentation changes - [x] [Tophatted documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md) changes in the style guide Co-authored-by: Chaz Dean <59836805+chazdean@users.noreply.github.com>
1 parent 35be8a0 commit ccdcea2

38 files changed

+254
-264
lines changed
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 `DisplayText`, `Heading`, `Subheading`, `Caption`, `TextStyle`, and `VisuallyHidden` components

.changeset/grumpy-donuts-agree.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'polaris.shopify.com': minor
3+
---
4+
5+
Deprecated `DisplayText`, `Heading`, `Subheading`, `Caption`, `TextStyle`, and `VisuallyHidden` pages and removed examples

polaris-react/playground/DetailsPage.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
import {
2020
ActionList,
2121
Badge,
22-
Caption,
2322
Card,
2423
ContextualSaveBar,
2524
DropZone,
@@ -36,12 +35,12 @@ import {
3635
SkeletonDisplayText,
3736
SkeletonPage,
3837
Stack,
38+
Text,
3939
TextContainer,
4040
TextField,
4141
Thumbnail,
4242
Toast,
4343
TopBar,
44-
VisuallyHidden,
4544
} from '../src';
4645

4746
import styles from './DetailsPage.scss';
@@ -451,7 +450,7 @@ export function DetailsPage() {
451450
const loadingMarkup = isLoading ? <Loading /> : null;
452451

453452
const skipToContentTarget = (
454-
<VisuallyHidden>
453+
<Text as="span" variant="bodySm" visuallyHidden>
455454
<a
456455
href="#SkipToContent"
457456
id="SkipToContentTarget"
@@ -460,7 +459,7 @@ export function DetailsPage() {
460459
>
461460
Page content
462461
</a>
463-
</VisuallyHidden>
462+
</Text>
464463
);
465464

466465
const [title, setTitle] = useState(
@@ -534,7 +533,10 @@ export function DetailsPage() {
534533
}
535534
/>
536535
<div>
537-
{file.name} <Caption>{file.size} bytes</Caption>
536+
{file.name}{' '}
537+
<Text as="p" variant="bodySm">
538+
{file.size} bytes
539+
</Text>
538540
</div>
539541
</Stack>
540542
))}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ export interface CaptionProps {
77
children?: React.ReactNode;
88
}
99

10+
/**
11+
* @deprecated The Caption component will be removed in the next
12+
* major version. Use the Text component instead. See the
13+
* Polaris component guide on how to use Text.
14+
*
15+
* https://polaris.shopify.com/components/text
16+
*/
1017
export function Caption({children}: CaptionProps) {
18+
if (process.env.NODE_ENV === 'development') {
19+
// eslint-disable-next-line no-console
20+
console.warn(
21+
'Deprecation: The `Caption` component has been deprecated. Use the `Text` component instead. See the Polaris component guide on how to use `Text`. https://polaris.shopify.com/components/text',
22+
);
23+
}
24+
1125
return <p className={styles.Caption}>{children}</p>;
1226
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import {mountWithApp} from 'tests/utilities';
33

4+
// eslint-disable-next-line import/no-deprecated
45
import {Caption} from '../Caption';
56

67
describe('<Caption />', () => {

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ export interface DisplayTextProps {
2222
children?: React.ReactNode;
2323
}
2424

25+
/**
26+
* @deprecated The DisplayText component will be removed in the next
27+
* major version. Use the Text component instead. See the
28+
* Polaris component guide on how to use Text.
29+
*
30+
* https://polaris.shopify.com/components/text
31+
*/
2532
export function DisplayText({
2633
element: Element = 'p',
2734
children,
@@ -32,5 +39,12 @@ export function DisplayText({
3239
size && styles[variationName('size', size)],
3340
);
3441

42+
if (process.env.NODE_ENV === 'development') {
43+
// eslint-disable-next-line no-console
44+
console.warn(
45+
'Deprecation: The `DisplayText` component has been deprecated. Use the `Text` component instead. See the Polaris component guide on how to use `Text`. https://polaris.shopify.com/components/text',
46+
);
47+
}
48+
3549
return <Element className={className}>{children}</Element>;
3650
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import {mountWithApp} from 'tests/utilities';
33

4+
// eslint-disable-next-line import/no-deprecated
45
import {DisplayText} from '../DisplayText';
56

67
describe('<DisplayText />', () => {

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,21 @@ export interface HeadingProps {
1616
id?: string;
1717
}
1818

19+
/**
20+
* @deprecated The Heading component will be removed in the next
21+
* major version. Use the Text component instead. See the
22+
* Polaris component guide on how to use Text.
23+
*
24+
* https://polaris.shopify.com/components/text
25+
*/
1926
export function Heading({element: Element = 'h2', children, id}: HeadingProps) {
27+
if (process.env.NODE_ENV === 'development') {
28+
// eslint-disable-next-line no-console
29+
console.warn(
30+
'Deprecation: The `Heading` component has been deprecated. Use the `Text` component instead. See the Polaris component guide on how to use `Text`. https://polaris.shopify.com/components/text',
31+
);
32+
}
33+
2034
return (
2135
<Element className={styles.Heading} id={id}>
2236
{children}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import {mountWithApp} from 'tests/utilities';
33

4+
// eslint-disable-next-line import/no-deprecated
45
import {Heading} from '../Heading';
56

67
describe('<Heading />', () => {

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,26 @@ export interface SubheadingProps {
1313
/** Text to display in subheading */
1414
children?: React.ReactNode;
1515
}
16-
16+
/**
17+
* @deprecated The Subheading component will be removed in the next
18+
* major version. Use the Text component instead. See the
19+
* Polaris component guide on how to use Text.
20+
*
21+
* https://polaris.shopify.com/components/text
22+
*/
1723
export function Subheading({
1824
element: Element = 'h3',
1925
children,
2026
}: SubheadingProps) {
2127
const ariaLabel = typeof children === 'string' ? children : undefined;
28+
29+
if (process.env.NODE_ENV === 'development') {
30+
// eslint-disable-next-line no-console
31+
console.warn(
32+
'Deprecation: The `Subheading` component has been deprecated. Use the `Text` component instead. See the Polaris component guide on how to use `Text`. https://polaris.shopify.com/components/text',
33+
);
34+
}
35+
2236
return (
2337
<Element aria-label={ariaLabel} className={styles.Subheading}>
2438
{children}

0 commit comments

Comments
 (0)