Skip to content

Commit 79d92a8

Browse files
sam-b-roselaurkimkyledurandalex-page
authored
Replace typography components with Text (#7530)
### WHY are these changes introduced? Resolves #6588, resolves #7192, resolves #7584, resolves #7047, resolves #7197, resolves #7048, resolves #7199, resolves #7206, resolves #7205, resolves #7598, resolves #7583. ### WHAT is this pull request doing? Replaces the old typography components with the new `Text` component. These changes where created using the `replace-text-component` migration: ```sh polaris-migrator replace-text-component "./polaris-react/src/**/*.tsx" --relative ``` Additionally, manual updates for the following text mixins have been updated to either use the `Text` component or the token inside the classes directly: - **text-style-body** - **text-style-heading** - **text-style-subheading** - **text-style-caption** - **text-style-button** - **text-style-button-large** - **text-emphasis-subdued** - **text-emphasis-strong** - **nav-item-text-attributes** Co-authored-by: Lo Kim <[email protected]> Co-authored-by: Kyle Durand <[email protected]> Co-authored-by: Alex Page <[email protected]>
1 parent ab0cf25 commit 79d92a8

File tree

111 files changed

+716
-426
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+716
-426
lines changed

.changeset/calm-wasps-cough.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@shopify/polaris': patch
3+
---
4+
5+
Replaced all typography components with the new `Text` component.
6+
Added support for `text-inverse` color type on `Text`.
7+
Removed references to the following mixins to use the new `Text` or tokens directly in classes: `text-style-body`, `text-style-heading`, `text-style-subheading`, `text-style-caption`, `text-style-button`, `text-style-button-large`, `text-emphasis-subdued`, `text-emphasis-strong`, `nav-item-text-attributes`.

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {Avatar} from '../Avatar';
55
import {buttonFrom} from '../Button';
66
import {Card} from '../Card';
77
import {Stack} from '../Stack';
8-
import {TextStyle} from '../TextStyle';
8+
import {Text} from '../Text';
99
import {SettingAction} from '../SettingAction';
1010

1111
import styles from './AccountConnection.scss';
@@ -61,7 +61,9 @@ export function AccountConnection({
6161

6262
const detailsMarkup = details ? (
6363
<div>
64-
<TextStyle variation="subdued">{details}</TextStyle>
64+
<Text variant="bodyMd" color="subdued" as="span">
65+
{details}
66+
</Text>
6567
</div>
6668
) : null;
6769

polaris-react/src/components/ActionList/ActionList.scss

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
outline: none;
1616
list-style: none;
1717
margin: 0;
18-
border-top: var(--p-border-divider);
18+
border-bottom: var(--p-border-divider);
1919
padding: var(--p-space-2);
2020
}
2121

@@ -24,16 +24,22 @@
2424
// stylelint-disable-next-line selector-max-class, selector-max-combinators, selector-max-specificity
2525
> .Section-withoutTitle .Actions {
2626
border-top: none;
27+
border-bottom: none;
2728
}
2829
}
2930

30-
.Title {
31-
@include text-style-subheading;
32-
padding: var(--p-space-3) var(--p-space-4) var(--p-space-3) var(--p-space-4);
31+
.ActionList .Section {
32+
// stylelint-disable-next-line selector-max-class, selector-max-combinators
33+
.Actions {
34+
padding-top: 0;
35+
}
3336
}
3437

35-
.Section:not(:first-child) .Title {
36-
padding-top: var(--p-space-1);
38+
.ActionList .Section:last-child {
39+
// stylelint-disable-next-line selector-max-class, selector-max-combinators, selector-max-specificity
40+
.Actions {
41+
border-bottom: none;
42+
}
3743
}
3844

3945
.Item {

polaris-react/src/components/ActionList/components/Item/Item.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {Scrollable} from '../../../Scrollable';
66
import {Icon} from '../../../Icon';
77
import {UnstyledLink} from '../../../UnstyledLink';
88
import {Badge} from '../../../Badge';
9-
import {TextStyle} from '../../../TextStyle';
9+
import {Text} from '../../../Text';
1010
import styles from '../../ActionList.scss';
1111
import {handleMouseUpByBlurring} from '../../../../utilities/focus';
1212

@@ -63,7 +63,9 @@ export function Item({
6363
const contentMarkup = helpText ? (
6464
<span className={styles.ContentBlock}>
6565
<span className={styles.ContentBlockInner}>{contentText}</span>
66-
<TextStyle variation="subdued">{helpText}</TextStyle>
66+
<Text variant="bodyMd" color="subdued" as="span">
67+
{helpText}
68+
</Text>
6769
</span>
6870
) : (
6971
contentText

polaris-react/src/components/ActionList/components/Item/tests/Item.test.tsx

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

44
import {Item} from '../Item';
5-
import {TextStyle} from '../../../../TextStyle';
5+
import {Text} from '../../../../Text';
66
import {UnstyledLink} from '../../../../UnstyledLink';
77

88
describe('<Item />', () => {
@@ -54,7 +54,7 @@ describe('<Item />', () => {
5454
it('renders helpText when the helpText prop is defined', () => {
5555
const helpText = 'Foo';
5656
const item = mountWithApp(<Item helpText={helpText} />);
57-
expect(item.find(TextStyle)).toContainReactText(helpText);
57+
expect(item.find(Text)).toContainReactText(helpText);
5858
});
5959

6060
it('passes `accessibilityLabel` to `<button />`', () => {

polaris-react/src/components/ActionList/components/Section/Section.tsx

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

33
import {Item} from '../Item';
4+
import {Box} from '../../../Box';
5+
import {Text} from '../../../Text';
46
import type {
57
ActionListItemDescriptor,
68
ActionListSection,
@@ -56,7 +58,16 @@ export function Section({
5658
const className = section.title ? undefined : styles['Section-withoutTitle'];
5759

5860
const titleMarkup = section.title ? (
59-
<p className={styles.Title}>{section.title}</p>
61+
<Box
62+
paddingBlockStart="4"
63+
paddingInlineStart="4"
64+
paddingBlockEnd="2"
65+
paddingInlineEnd="4"
66+
>
67+
<Text as="p" variant="headingXs">
68+
{section.title}
69+
</Text>
70+
</Box>
6071
) : null;
6172

6273
let sectionRole;

polaris-react/src/components/AppProvider/AppProvider.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@
66

77
html,
88
body {
9-
@include text-style-body;
9+
font-size: var(--p-font-size-100);
10+
line-height: var(--p-font-line-height-2);
11+
font-weight: var(--p-font-weight-regular);
12+
13+
text-transform: initial;
14+
letter-spacing: initial;
15+
1016
@include text-emphasis-normal;
1117
}
1218

polaris-react/src/components/Autocomplete/components/MappedAction/MappedAction.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {classNames} from '../../../../utilities/css';
66
import {MappedActionContext} from '../../../../utilities/autocomplete';
77
import {Listbox} from '../../../Listbox';
88
import {Icon} from '../../../Icon';
9-
import {TextStyle} from '../../../TextStyle';
9+
import {Text} from '../../../Text';
1010
import {useI18n} from '../../../../utilities/i18n';
1111

1212
import styles from './MappedAction.scss';
@@ -75,7 +75,11 @@ export function MappedAction({
7575
const contentMarkup = (
7676
<div className={styles.Text}>
7777
<div className={contentOverflowStyle}>{contentText}</div>
78-
{helpText ? <TextStyle variation="subdued">{helpText}</TextStyle> : null}
78+
{helpText ? (
79+
<Text variant="bodyMd" color="subdued" as="span">
80+
{helpText}
81+
</Text>
82+
) : null}
7983
</div>
8084
);
8185

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

Lines changed: 67 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ export function ExtraSmall() {
4141
);
4242
}
4343

44-
export function Square() {
45-
return <Avatar name="Shop One" shape="square" />;
46-
}
47-
4844
export function ExternalImage() {
4945
return (
5046
<Avatar
@@ -55,20 +51,82 @@ export function ExternalImage() {
5551
);
5652
}
5753

54+
export function Square() {
55+
return <Avatar name="Shop One" shape="square" />;
56+
}
57+
58+
export function SquareWithInitials() {
59+
return (
60+
<Stack vertical>
61+
<Stack.Item>
62+
<Avatar
63+
shape="square"
64+
initials="OE"
65+
name="Oluwayemisi Eun-Jung"
66+
size="extraSmall"
67+
/>
68+
</Stack.Item>
69+
<Stack.Item>
70+
<Avatar
71+
shape="square"
72+
initials="OE"
73+
name="Oluwayemisi Eun-Jung"
74+
size="small"
75+
/>
76+
</Stack.Item>
77+
<Stack.Item>
78+
<Avatar
79+
shape="square"
80+
initials="OE"
81+
name="Oluwayemisi Eun-Jung"
82+
size="medium"
83+
/>
84+
</Stack.Item>
85+
<Stack.Item>
86+
<Avatar
87+
shape="square"
88+
initials="OE"
89+
name="Oluwayemisi Eun-Jung"
90+
size="large"
91+
/>
92+
</Stack.Item>
93+
</Stack>
94+
);
95+
}
96+
5897
export function Sizes() {
5998
return (
60-
<Stack>
99+
<Stack vertical>
100+
<Stack.Item>
101+
<Avatar name="Farrah" size="extraSmall" />
102+
</Stack.Item>
103+
<Stack.Item>
104+
<Avatar name="Farrah" size="small" />
105+
</Stack.Item>
106+
<Stack.Item>
107+
<Avatar name="Farrah" size="medium" />
108+
</Stack.Item>
109+
<Stack.Item>
110+
<Avatar name="Farrah" size="large" />
111+
</Stack.Item>
112+
</Stack>
113+
);
114+
}
115+
116+
export function SizesWithInitials() {
117+
return (
118+
<Stack vertical>
61119
<Stack.Item>
62-
<Avatar customer name="Farrah" size="extraSmall" />
120+
<Avatar initials="OE" name="Oluwayemisi Eun-Jung" size="extraSmall" />
63121
</Stack.Item>
64122
<Stack.Item>
65-
<Avatar customer name="Farrah" size="small" />
123+
<Avatar initials="OE" name="Oluwayemisi Eun-Jung" size="small" />
66124
</Stack.Item>
67125
<Stack.Item>
68-
<Avatar customer name="Farrah" size="medium" />
126+
<Avatar initials="OE" name="Oluwayemisi Eun-Jung" size="medium" />
69127
</Stack.Item>
70128
<Stack.Item>
71-
<Avatar customer name="Farrah" size="large" />
129+
<Avatar initials="OE" name="Oluwayemisi Eun-Jung" size="large" />
72130
</Stack.Item>
73131
</Stack>
74132
);

polaris-react/src/components/Badge/Badge.scss

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,12 @@
66
padding: var(--pc-badge-vertical-padding) var(--pc-badge-horizontal-padding);
77
background-color: var(--p-surface-neutral);
88
border-radius: var(--p-border-radius-5);
9-
font-size: 13px;
10-
line-height: var(--p-font-line-height-1);
11-
color: var(--p-text);
12-
font-weight: var(--p-font-weight-regular);
139

1410
@media print {
1511
border: solid var(--p-border-width-1) var(--p-border);
1612
}
1713
}
1814

19-
.sizeSmall {
20-
font-size: var(--p-font-size-75);
21-
}
22-
2315
.statusSuccess {
2416
background-color: var(--p-surface-success);
2517
color: var(--p-text);

0 commit comments

Comments
 (0)