Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/slimy-tips-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': minor
---

Deprecated `heading2xl` and `heading3xl` variants in `Text` component
21 changes: 21 additions & 0 deletions documentation/Deprecation guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,26 @@ Follow these guidelines for deprecating [components](#components), [props](#prop
## Prop values

- Mark the prop value(s) as deprecated

- Add a console.warn() for deprecated prop value(s) to component

```tsx
const deprecatedVariants: {[V in Variant]?: Variant} = {
heading2xl: 'headingXl',
heading3xl: 'headingXl',
};

if (
process.env.NODE_ENV === 'development' &&
variant &&
Object.prototype.hasOwnProperty.call(deprecatedVariants, variant)
) {
console.warn(
`Deprecation: <Text variant="${variant}" />. The value "${variant}" will be removed in a future major version of Polaris. Use "${deprecatedVariants[variant]}" instead.`,
);
}
```

- Add component, prop, and deprecated prop value(s) to `componentUnionTypeDeprecations` ([example](https://github.com/Shopify/polaris/tree/main/polaris.shopify.com/pages/components/%5Bgroup%5D/%5Bcomponent%5D/index.tsx#L80))
```tsx
const componentUnionTypeDeprecations: {
Expand All @@ -55,6 +75,7 @@ Follow these guidelines for deprecating [components](#components), [props](#prop
};
```
- Check documentation is updated on polaris.shopify.com

- Create automated migration(s) ([examples](https://github.com/Shopify/polaris/tree/main/polaris-migrator/src/migrations))
- Add supporting documentation for deprecation in next major version guide ([examples](https://github.com/Shopify/polaris/tree/main/polaris.shopify.com/content/version-guides/migrating-from-v11-to-v12.mdx#L122))
- Document deprecation reason
Expand Down
15 changes: 15 additions & 0 deletions polaris-react/src/components/Text/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ type Tone =

type TextDecorationLine = 'line-through';

const deprecatedVariants: {[V in Variant]?: Variant} = {
heading2xl: 'headingXl',
heading3xl: 'headingXl',
};
export interface TextProps {
/** Adjust horizontal alignment of text */
alignment?: Alignment;
Expand Down Expand Up @@ -88,6 +92,17 @@ export const Text = ({
visuallyHidden = false,
textDecorationLine,
}: TextProps) => {
if (
process.env.NODE_ENV === 'development' &&
variant &&
Object.prototype.hasOwnProperty.call(deprecatedVariants, variant)
) {
// eslint-disable-next-line no-console
console.warn(
`Deprecation: <Text variant="${variant}" />. The value "${variant}" will be removed in a future major version of Polaris. Use "${deprecatedVariants[variant]}" instead.`,
);
}

const Component = as || (visuallyHidden ? 'span' : 'p');

const className = classNames(
Expand Down