Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
32 changes: 32 additions & 0 deletions docs/data/material/migration/upgrade-to-v9/upgrade-to-v9.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,23 @@ If you were using `MuiTouchRipple` in your theme, remove it and use global CSS w
});
```

### Typography

#### Deprecated props removed

The deprecated `paragraph` prop and `typographyClasses.paragraph` have been removed.

Migrate to `component` prop with the codemod below:

```bash
npx @mui/codemod@next deprecations/typography-props <path>
```

```diff
- <Typography paragraph>Hello</Typography>
+ <Typography component="p" sx={{ mb: 2 }}>Hello</Typography>
```

### JSDOM support

v9 removes all usage of `process.env.NODE_ENV === 'test'`. The `NODE_ENV` variable will exclusively be used for for tree-shaking. Our libraries have been updated to auto-detect DOM environments that don't support layout such as [JSDOM](https://github.com/jsdom/jsdom) and [happy-dom](https://github.com/capricorn86/happy-dom) through user agent sniffing.
Expand Down Expand Up @@ -471,3 +488,18 @@ If you render a `TextField` from `Autocomplete`, the `params` shape also changed
)}
/>
```

Comment thread
siriwatknp marked this conversation as resolved.
#### Typography deprecated props removed

Use the [typography-props codemod](https://github.com/mui/material-ui/tree/HEAD/packages/mui-codemod#typography-props) below to migrate the code as described in the following section:

```bash
npx @mui/codemod@latest deprecations/typography-props <path>
```

The deprecated `paragraph` prop and `typographyClasses.paragraph` have been removed.

```diff
- <Typography paragraph>Hello</Typography>
+ <Typography component="p" sx={{ mb: 2 }}>Hello</Typography>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to show something for the removed typographyClasses.paragraph in the diff?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true. Let me add it.

```
Comment thread
siriwatknp marked this conversation as resolved.
13 changes: 0 additions & 13 deletions docs/pages/material-ui/api/typography.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@
"component": { "type": { "name": "elementType" } },
"gutterBottom": { "type": { "name": "bool" }, "default": "false" },
"noWrap": { "type": { "name": "bool" }, "default": "false" },
"paragraph": {
"type": { "name": "bool" },
"default": "false",
"deprecated": true,
"deprecationInfo": "Use the <code>component</code> prop instead. This prop will be removed in a future major release. See <a href=\"https://mui.com/material-ui/migration/migrating-from-deprecated-apis/\">Migrating from deprecated APIs</a> for more details."
},
"sx": {
"type": {
"name": "union",
Expand Down Expand Up @@ -157,13 +151,6 @@
"description": "Styles applied to the root element if `variant=\"overline\"`.",
"isGlobal": false
},
{
"key": "paragraph",
"className": "MuiTypography-paragraph",
"description": "Styles applied to the root element if `paragraph={true}`.",
"isGlobal": false,
"isDeprecated": true
},
{
"key": "root",
"className": "MuiTypography-root",
Expand Down
8 changes: 0 additions & 8 deletions docs/translations/api-docs/typography/typography.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
"noWrap": {
"description": "If <code>true</code>, the text will not wrap, but instead will truncate with a text overflow ellipsis.<br>Note that text overflow can only happen with block or inline-block level elements (the element needs to have a width in order to overflow)."
},
"paragraph": {
"description": "If <code>true</code>, the element will be a paragraph element."
},
"sx": {
"description": "The system prop that allows defining system overrides as well as additional CSS styles."
},
Expand Down Expand Up @@ -116,11 +113,6 @@
"nodeName": "the root element",
"conditions": "<code>variant=\"overline\"</code>"
},
"paragraph": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>paragraph={true}</code>"
},
"root": { "description": "Styles applied to the root element." },
"subtitle1": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
Expand Down
6 changes: 0 additions & 6 deletions packages/mui-material/src/Typography/Typography.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ export interface TypographyOwnProps extends Omit<SystemProps<Theme>, 'color'> {
* @default false
*/
noWrap?: boolean | undefined;
/**
* If `true`, the element will be a paragraph element.
* @default false
* @deprecated Use the `component` prop instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
*/
paragraph?: boolean | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
Expand Down
22 changes: 2 additions & 20 deletions packages/mui-material/src/Typography/Typography.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const v6Colors = {
const extendSxProp = internal_createExtendSxProp();

const useUtilityClasses = (ownerState) => {
const { align, gutterBottom, noWrap, paragraph, variant, classes } = ownerState;
const { align, gutterBottom, noWrap, variant, classes } = ownerState;

const slots = {
root: [
Expand All @@ -34,7 +34,6 @@ const useUtilityClasses = (ownerState) => {
ownerState.align !== 'inherit' && `align${capitalize(align)}`,
gutterBottom && 'gutterBottom',
noWrap && 'noWrap',
paragraph && 'paragraph',
],
};

Expand All @@ -53,7 +52,6 @@ export const TypographyRoot = styled('span', {
ownerState.align !== 'inherit' && styles[`align${capitalize(ownerState.align)}`],
ownerState.noWrap && styles.noWrap,
ownerState.gutterBottom && styles.gutterBottom,
ownerState.paragraph && styles.paragraph,
];
},
})(
Expand Down Expand Up @@ -113,12 +111,6 @@ export const TypographyRoot = styled('span', {
marginBottom: '0.35em',
},
},
{
props: ({ ownerState }) => ownerState.paragraph,
style: {
marginBottom: 16,
},
},
],
})),
);
Expand Down Expand Up @@ -152,7 +144,6 @@ const Typography = React.forwardRef(function Typography(inProps, ref) {
component,
gutterBottom = false,
noWrap = false,
paragraph = false,
variant = 'body1',
variantMapping = defaultVariantMapping,
...other
Expand All @@ -166,15 +157,12 @@ const Typography = React.forwardRef(function Typography(inProps, ref) {
component,
gutterBottom,
noWrap,
paragraph,
variant,
variantMapping,
};

const Component =
component ||
(paragraph ? 'p' : variantMapping[variant] || defaultVariantMapping[variant]) ||
'span';
component || variantMapping[variant] || defaultVariantMapping[variant] || 'span';

const classes = useUtilityClasses(ownerState);

Expand Down Expand Up @@ -252,12 +240,6 @@ Typography.propTypes /* remove-proptypes */ = {
* @default false
*/
noWrap: PropTypes.bool,
/**
* If `true`, the element will be a paragraph element.
* @default false
* @deprecated Use the `component` prop instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
*/
paragraph: PropTypes.bool,
/**
* @ignore
*/
Expand Down
6 changes: 0 additions & 6 deletions packages/mui-material/src/Typography/Typography.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ describe('<Typography />', () => {
expect(screen.getByText(/hello/i).tagName).to.equal('SPAN');
});

it('should render a p with a paragraph', () => {
render(<Typography paragraph>Hello</Typography>);

expect(screen.getByText(/hello/i).tagName).to.equal('P');
});

it('should render the mapped headline', () => {
render(<Typography variant="h6">Hello</Typography>);

Expand Down
6 changes: 0 additions & 6 deletions packages/mui-material/src/Typography/typographyClasses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ export interface TypographyClasses {
noWrap: string;
/** Styles applied to the root element if `gutterBottom={true}`. */
gutterBottom: string;
/**
* Styles applied to the root element if `paragraph={true}`.
* @deprecated
*/
paragraph: string;
}

export type TypographyClassKey = keyof TypographyClasses;
Expand Down Expand Up @@ -79,7 +74,6 @@ const typographyClasses: TypographyClasses = generateUtilityClasses('MuiTypograp
'alignJustify',
'noWrap',
'gutterBottom',
'paragraph',
]);

export default typographyClasses;
Loading