Skip to content

Commit

Permalink
[theme] Add warning for theme.typography.round deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
m4theushw committed Apr 23, 2021
1 parent 368f282 commit 93bc814
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion packages/material-ui/src/styles/createTypography.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ function round(value) {
return Math.round(value * 1e5) / 1e5;
}

let warnedOnce = false;

function roundWithDeprecationWarning(value) {
if (process.env.NODE_ENV !== 'production') {
if (!warnedOnce) {
console.warn(
[
'Material-UI: The `theme.typography.round` helper is deprecated.',
'Head to https://material-ui.com/r/migration-v4/#theme for a migration path.',
].join('\n'),
);
warnedOnce = true;
}
}

return round(value);
}

const caseAllCaps = {
textTransform: 'uppercase',
};
Expand Down Expand Up @@ -78,7 +96,7 @@ export default function createTypography(palette, typography) {
{
htmlFontSize,
pxToRem,
round, // TODO v5: remove
round: roundWithDeprecationWarning, // TODO v5: remove
fontFamily,
fontSize,
fontWeightLight,
Expand Down

0 comments on commit 93bc814

Please sign in to comment.