Skip to content

Commit cb41f71

Browse files
alex-pagekyledurandaaronccasanova
authored
variant prop on Text component not required (#8539)
Fixes #7645 and fixes #8516 - [x] Makes `variant` optional - [x] Makes `font-weight` added only if there is a variant that has a fontWeight or a fontWeight is provided - [x] Adds a test for `font-weight` adding logic - [x] Removes `variant` from all `<Text>` components with `visuallyHidden` - [ ] Removes `variant` from components where they only add a visual style like `color` `fontWeight` and do not need to change their `font-size` and `line-height` To tophat this change: - [x] Compare visual difference in chromatic - [x] Check the changed storybook stories --------- Co-authored-by: Kyle Durand <[email protected]> Co-authored-by: Aaron Casanova <[email protected]>
1 parent 7e778ee commit cb41f71

File tree

84 files changed

+387
-573
lines changed

Some content is hidden

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

84 files changed

+387
-573
lines changed

.changeset/real-turkeys-poke.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+
Updated `variant` prop on `Text` component to be optional to better support children with similar styles

polaris-react/playground/DetailsPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ export function DetailsPage() {
451451
const loadingMarkup = isLoading ? <Loading /> : null;
452452

453453
const skipToContentTarget = (
454-
<Text as="span" variant="bodySm" visuallyHidden>
454+
<Text as="span" visuallyHidden>
455455
<a
456456
href="#SkipToContent"
457457
id="SkipToContentTarget"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export function AccountConnection({
5555
const titleMarkup = title ? title : accountName;
5656

5757
const detailsMarkup = details ? (
58-
<Text as="span" variant="bodyMd" color="subdued">
58+
<Text as="span" color="subdued">
5959
{details}
6060
</Text>
6161
) : null;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export function Item({
6666
const contentMarkup = helpText ? (
6767
<>
6868
<Box>{contentText}</Box>
69-
<Text variant="bodyMd" color="subdued" as="span">
69+
<Text color="subdued" as="span">
7070
{helpText}
7171
</Text>
7272
</>

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ export function Default() {
2121
<Text as="h3" variant="headingMd">
2222
Online store dashboard
2323
</Text>
24-
<Text variant="bodyMd" as="p">
25-
View a summary of your online store’s performance.
26-
</Text>
24+
<p>View a summary of your online store’s performance.</p>
2725
</AlphaStack>
2826
</AlphaCard>
2927
);
@@ -36,9 +34,7 @@ export function WithBackgroundSubdued() {
3634
<Text as="h3" variant="headingMd">
3735
Online store dashboard
3836
</Text>
39-
<Text variant="bodyMd" as="p">
40-
View a summary of your online store’s performance.
41-
</Text>
37+
<p>View a summary of your online store’s performance.</p>
4238
</AlphaStack>
4339
</AlphaCard>
4440
);
@@ -51,9 +47,7 @@ export function WithBorderRadiusRoundedAbove() {
5147
<Text as="h3" variant="headingMd">
5248
Online store dashboard
5349
</Text>
54-
<Text variant="bodyMd" as="p">
55-
View a summary of your online store’s performance.
56-
</Text>
50+
<p>View a summary of your online store’s performance.</p>
5751
</AlphaStack>
5852
</AlphaCard>
5953
);
@@ -66,9 +60,7 @@ export function WithResponsivePadding() {
6660
<Text as="h3" variant="headingMd">
6761
Online store dashboard
6862
</Text>
69-
<Text variant="bodyMd" as="p">
70-
View a summary of your online store’s performance.
71-
</Text>
63+
<p>View a summary of your online store’s performance.</p>
7264
</AlphaStack>
7365
</AlphaCard>
7466
);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export function Default() {
6363
return (
6464
<ResourceList.Item id={id} url={url} media={media}>
6565
<h3>
66-
<Text variant="bodyMd" fontWeight="bold" as="span">
66+
<Text fontWeight="bold" as="span">
6767
{name}
6868
</Text>
6969
</h3>
@@ -123,7 +123,7 @@ export function WithI18n() {
123123
return (
124124
<ResourceList.Item id={id} url={url} media={media}>
125125
<h3>
126-
<Text variant="bodyMd" fontWeight="bold" as="span">
126+
<Text fontWeight="bold" as="span">
127127
{name}
128128
</Text>
129129
</h3>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export function MappedAction({
7676
<div className={styles.Text}>
7777
<div className={contentOverflowStyle}>{contentText}</div>
7878
{helpText ? (
79-
<Text variant="bodyMd" color="subdued" as="span">
79+
<Text color="subdued" as="span">
8080
{helpText}
8181
</Text>
8282
) : null}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export function Badge({
6363
: getDefaultAccessibilityLabel(i18n, progress, status);
6464

6565
let accessibilityMarkup = Boolean(accessibilityLabel) && (
66-
<Text variant="bodySm" as="span" visuallyHidden>
66+
<Text as="span" visuallyHidden>
6767
{accessibilityLabel}
6868
</Text>
6969
);

polaris-react/src/components/Badge/components/Pip/Pip.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function Pip({
3232

3333
return (
3434
<span className={className}>
35-
<Text variant="bodySm" as="span" visuallyHidden>
35+
<Text as="span" visuallyHidden>
3636
{accessibilityLabel}
3737
</Text>
3838
</span>

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,33 +63,25 @@ export function WithHorizontalDirection() {
6363
export function WithSpecificDirection() {
6464
return (
6565
<LegacyStack vertical>
66-
<Text variant="bodyMd" as="p">
67-
Block Start
68-
</Text>
66+
<p>Block Start</p>
6967
<Box background="surface" padding="4" border="base">
7068
<Bleed marginInline="4" marginBlockStart="6">
7169
<div style={styles} />
7270
</Bleed>
7371
</Box>
74-
<Text variant="bodyMd" as="p">
75-
Block End
76-
</Text>
72+
<p>Block End</p>
7773
<Box background="surface" padding="4" border="base">
7874
<Bleed marginInline="4" marginBlockEnd="6">
7975
<div style={styles} />
8076
</Bleed>
8177
</Box>
82-
<Text variant="bodyMd" as="p">
83-
Inline Start
84-
</Text>
78+
<p>Inline Start</p>
8579
<Box background="surface" padding="4" border="base">
8680
<Bleed marginInline="0" marginInlineStart="6">
8781
<div style={styles} />
8882
</Bleed>
8983
</Box>
90-
<Text variant="bodyMd" as="p">
91-
Inline End
92-
</Text>
84+
<p>Inline End</p>
9385
<Box background="surface" padding="4" border="base">
9486
<Bleed marginInline="0" marginInlineEnd="6">
9587
<div style={styles} />

0 commit comments

Comments
 (0)