Skip to content

Commit

Permalink
chore: update badge props and tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
kyledurand committed Sep 1, 2023
1 parent 10d3c00 commit 711dd9a
Show file tree
Hide file tree
Showing 51 changed files with 244 additions and 254 deletions.
4 changes: 4 additions & 0 deletions documentation/guides/migrating-from-v11-to-v12.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Polaris v12.0.0 ([full release notes](https://github.com/Shopify/polaris/release

## Quick migration guide

**Badge**

`npx @shopify/polaris-migrator react-rename-component-prop <path> --componentName="Text" --from="status" --to="tone"`

**Layout.Section**

- One third:
Expand Down
2 changes: 1 addition & 1 deletion polaris-react/playground/DetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ export function DetailsPage() {
fullWidth
backAction={{content: 'Products', url: '/products/31'}}
title={title}
titleMetadata={<Badge status="success">Success badge</Badge>}
titleMetadata={<Badge tone="success">Success badge</Badge>}
primaryAction={{
content: 'Save this page',
onAction: () => console.log('save'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export function Item({

const badgeMarkup = badge && (
<span className={styles.Suffix}>
<Badge status={badge.status}>{badge.content}</Badge>
<Badge tone={badge.tone}>{badge.content}</Badge>
</span>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ describe('<ActionList />', () => {
const actionList = mountWithApp(
<ActionList
items={[
{content: 'Add discount', badge: {status: 'new', content: 'badge'}},
{content: 'Add discount', badge: {tone: 'new', content: 'badge'}},
]}
onActionAnyItem={mockOnActionAnyItem}
actionRole="option"
/>,
);
expect(actionList).toContainReactComponent(Badge, {
children: 'badge',
status: 'new',
tone: 'new',
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function MappedAction({

const badgeMarkup = badge && (
<span className={styles.Suffix}>
<Badge status={badge.status}>{badge.content}</Badge>
<Badge tone={badge.tone}>{badge.content}</Badge>
</span>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import {Icon} from '../../../../Icon';
describe('MappedAction', () => {
it('renders badge when provided', () => {
const badge = {
status: 'new' as const,
tone: 'new' as const,
content: 'new',
};
const mappedAction = mountWithListboxProvider(
<MappedAction badge={badge} />,
);

expect(mappedAction).toContainReactComponent(Badge, {
status: badge.status,
tone: badge.tone,
children: badge.content,
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ describe('<Autocomplete/>', () => {
disabled: false,
destructive: true,
badge: {
status: 'new' as const,
tone: 'new' as const,
content: 'new',
},
};
Expand All @@ -250,7 +250,7 @@ describe('<Autocomplete/>', () => {
disabled: false,
destructive: true,
badge: {
status: 'new' as const,
tone: 'new' as const,
content: 'new',
},
};
Expand Down
30 changes: 15 additions & 15 deletions polaris-react/src/components/Badge/Badge.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}
}

.statusSuccess {
.toneSuccess {
background-color: var(--p-color-bg-success);
color: var(--p-color-text-success);

Expand All @@ -32,7 +32,7 @@
}
}

.statusSuccess-strong-experimental {
.toneSuccess-strong {
color: var(--p-color-text-on-color);
background-color: var(--p-color-bg-success-strong);

Expand All @@ -41,7 +41,7 @@
}
}

.statusInfo {
.toneInfo {
background-color: var(--p-color-bg-info);
color: var(--p-color-text-info);

Expand All @@ -50,7 +50,7 @@
}
}

.statusInfo-strong-experimental {
.toneInfo-strong {
color: var(--p-color-text-info-strong);
background-color: var(--p-color-bg-info-strong);

Expand All @@ -59,7 +59,7 @@
}
}

.statusAttention {
.toneAttention {
background-color: var(--p-color-bg-caution);
color: var(--p-color-text-caution);

Expand All @@ -68,7 +68,7 @@
}
}

.statusAttention-strong-experimental {
.toneAttention-strong {
color: var(--p-color-text-caution-strong);
background-color: var(--p-color-bg-caution-strong);

Expand All @@ -77,7 +77,7 @@
}
}

.statusWarning {
.toneWarning {
background-color: var(--p-color-bg-warning);
color: var(--p-color-text-warning-experimental);

Expand All @@ -86,7 +86,7 @@
}
}

.statusWarning-strong-experimental {
.toneWarning-strong {
color: var(--p-color-text-warning-experimental);
background-color: var(--p-color-bg-warning-strong-experimental);

Expand All @@ -95,7 +95,7 @@
}
}

.statusCritical {
.toneCritical {
background-color: var(--p-color-bg-critical);
color: var(--p-color-text-critical);

Expand All @@ -104,7 +104,7 @@
}
}

.statusCritical-strong-experimental {
.toneCritical-strong {
color: var(--p-color-text-on-color);
background-color: var(--p-color-bg-critical-strong);

Expand All @@ -113,7 +113,7 @@
}
}

.statusNew {
.toneNew {
border: none;
background-color: var(--p-color-bg-transparent-subdued-experimental);
color: var(--p-color-text-subdued);
Expand All @@ -125,7 +125,7 @@
}
}

.statusRead-only-experimental {
.toneRead-only {
color: var(--p-color-text-subdued);
background-color: transparent;

Expand All @@ -134,15 +134,15 @@
}
}

.statusEnabled-experimental {
.toneEnabled {
color: var(--p-color-text);

svg {
fill: var(--p-color-icon-success);
}
}

.sizeLarge-experimental {
.sizeLarge {
padding: var(--p-space-1) var(--p-space-2);
}

Expand All @@ -160,7 +160,7 @@
vertical-align: top;
}

.sizeLarge-experimental & {
.sizeLarge & {
margin: 0 var(--p-space-1) 0 calc(-1 * var(--p-space-05));
}

Expand Down
Loading

0 comments on commit 711dd9a

Please sign in to comment.