From 93bc814651a4eb21ea8cfe26d12a5436374412b2 Mon Sep 17 00:00:00 2001 From: Matheus Wichman Date: Fri, 23 Apr 2021 18:55:32 -0300 Subject: [PATCH] [theme] Add warning for theme.typography.round deprecation --- .../src/styles/createTypography.js | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/material-ui/src/styles/createTypography.js b/packages/material-ui/src/styles/createTypography.js index 9aaf9f33a91706..216e8404efaf82 100644 --- a/packages/material-ui/src/styles/createTypography.js +++ b/packages/material-ui/src/styles/createTypography.js @@ -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', }; @@ -78,7 +96,7 @@ export default function createTypography(palette, typography) { { htmlFontSize, pxToRem, - round, // TODO v5: remove + round: roundWithDeprecationWarning, // TODO v5: remove fontFamily, fontSize, fontWeightLight,