Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Box] Deprecate system props #23206

Merged
merged 84 commits into from
Oct 23, 2020
Merged
Show file tree
Hide file tree
Changes from 81 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
c2d31cc
add emotion peer dependencies
mnajdova Sep 25, 2020
5ae933f
fixed types & tests
mnajdova Sep 25, 2020
18b0668
prettier
mnajdova Sep 25, 2020
f0ef95c
Merge branch 'next' of https://github.com/mui-org/material-ui into next
mnajdova Sep 28, 2020
c7bebb8
Merge branch 'next' of https://github.com/mui-org/material-ui into next
mnajdova Sep 28, 2020
92b2d6e
Merge branch 'next' of https://github.com/mui-org/material-ui into next
mnajdova Sep 28, 2020
13da531
Merge branch 'next' of https://github.com/mui-org/material-ui into next
mnajdova Sep 29, 2020
cf5d9a5
Merge branch 'next' of https://github.com/mui-org/material-ui into next
mnajdova Sep 29, 2020
b8d1291
Merge branch 'next' of https://github.com/mui-org/material-ui into next
mnajdova Sep 30, 2020
a9d8690
Merge branch 'next' of https://github.com/mui-org/material-ui into next
mnajdova Oct 2, 2020
74dc451
wip
mnajdova Oct 2, 2020
688d13a
fixed typo
mnajdova Oct 2, 2020
497830a
Merge branch 'next' of https://github.com/mui-org/material-ui into next
mnajdova Oct 5, 2020
d50ea1e
Merge branch 'next' of https://github.com/mui-org/material-ui into next
mnajdova Oct 5, 2020
a1da207
added cross-env
mnajdova Oct 5, 2020
6ff31f9
yarn lock
mnajdova Oct 5, 2020
9fd7f7b
version
mnajdova Oct 5, 2020
e561135
Merge branch 'feat/benchmark-window-fix' into feat/update-box-to-use-…
mnajdova Oct 5, 2020
2a71a6e
fixes
mnajdova Oct 5, 2020
77d6017
prettier
mnajdova Oct 5, 2020
a3beed3
removed cross-env dependency
mnajdova Oct 5, 2020
0b2d503
removed unused theme
mnajdova Oct 5, 2020
eddfa14
reversed style fn
mnajdova Oct 7, 2020
83e0ea2
sx wip
mnajdova Oct 8, 2020
ff2d4c3
Updated box filterProps
mnajdova Oct 8, 2020
f7a74e9
prettier
mnajdova Oct 8, 2020
bc55cdb
Merge remote-tracking branch 'origin/feat/update-box-to-use-emotion' …
mnajdova Oct 14, 2020
72893a9
merge conflicts
mnajdova Oct 14, 2020
d596058
cleanup
mnajdova Oct 14, 2020
94c905d
Update docs/src/pages/components/slider-styled/ContinuousSlider.js
mnajdova Oct 14, 2020
f179fb9
Update docs/src/pages/components/slider-styled/ContinuousSlider.tsx
mnajdova Oct 14, 2020
0373182
updated scenarios to be in the correct benchmark
mnajdova Oct 14, 2020
6021478
cleaned up benchmark scenarios
mnajdova Oct 14, 2020
5a70cf2
Merge branch 'feat/box-sx-prop' of https://github.com/mnajdova/materi…
mnajdova Oct 14, 2020
92847d7
Merge branch 'next' into feat/box-sx-prop
mnajdova Oct 15, 2020
d438191
fixed typings, updated box page
mnajdova Oct 15, 2020
7bab4bd
moved styleFunction to Box
mnajdova Oct 15, 2020
d966402
Update docs/src/pages/components/box/box.md
mnajdova Oct 15, 2020
76c0f7e
Update packages/material-ui-system/src/palette.js
mnajdova Oct 15, 2020
448bc82
Update packages/material-ui/src/Box/Box.js
mnajdova Oct 15, 2020
a7b690d
Update docs/src/pages/components/box/box.md
mnajdova Oct 15, 2020
59461b3
added support for functions for the values
mnajdova Oct 15, 2020
f6faf73
prettier
mnajdova Oct 15, 2020
c53c4bd
fixed sizing filterProps
mnajdova Oct 15, 2020
ed02098
support sx as function
mnajdova Oct 15, 2020
f1ae038
prettier
mnajdova Oct 15, 2020
d2756c7
implemented breakpoints, fixed types, removed theme function callback
mnajdova Oct 19, 2020
0f64e53
added theme-ui benchmark + sx prop benchmark for the box
mnajdova Oct 19, 2020
b32dd5a
fixed custom breakpoints support
mnajdova Oct 19, 2020
79af939
Update docs/src/pages/components/box/box.md
mnajdova Oct 20, 2020
64174a6
added theme-ui div scenario benchmark
mnajdova Oct 20, 2020
70c1d51
Merge branch 'feat/box-sx-prop' of https://github.com/mnajdova/materi…
mnajdova Oct 20, 2020
502733e
improved examples, added chakra-ui box & added results in readme
mnajdova Oct 20, 2020
49641ac
added tests, fixes
mnajdova Oct 20, 2020
15b118b
breakpoints more tests and fixes
mnajdova Oct 20, 2020
b386b29
improved breakpoints checks
mnajdova Oct 20, 2020
e200326
added more examples
mnajdova Oct 20, 2020
e12c35f
Added Box examples
mnajdova Oct 20, 2020
d32da87
temporarly removed dependency
mnajdova Oct 20, 2020
2d4c5c9
Merge branch 'next' into feat/box-sx-prop
mnajdova Oct 20, 2020
80682d1
reverted yarn.lock changes
mnajdova Oct 20, 2020
6533c27
reverted benchmark changes
mnajdova Oct 20, 2020
5df2f8c
Merge branch 'next' into feat/box-sx-prop
mnajdova Oct 20, 2020
3767add
Update benchmark/browser/README.md
mnajdova Oct 20, 2020
dce99bc
reverted some changes
mnajdova Oct 20, 2020
9671da1
Merge branch 'feat/box-sx-prop' of https://github.com/mnajdova/materi…
mnajdova Oct 20, 2020
b0cc366
fixed lint & tests
mnajdova Oct 20, 2020
0b1ecd5
Merge branch 'next' into feat/box-sx-prop
mnajdova Oct 21, 2020
9e3ad18
fixed breakpoints merging
mnajdova Oct 21, 2020
2e557d4
prettier
mnajdova Oct 21, 2020
f00fd05
lint
mnajdova Oct 21, 2020
43b629d
Update benchmark/browser/scenarios/sx-prop-box-material-ui/index.js
mnajdova Oct 21, 2020
0d57b2d
Update benchmark/browser/scripts/benchmark.js
mnajdova Oct 21, 2020
676692d
added deprecation message
mnajdova Oct 21, 2020
272380f
Merge branch 'next' into feat/box-deprecate-system-props
mnajdova Oct 22, 2020
2dd4913
removed duplicated example
mnajdova Oct 22, 2020
a722e51
prettier
mnajdova Oct 22, 2020
2a24e55
Update packages/material-ui/src/Box/Box.js
mnajdova Oct 22, 2020
21f217d
Update packages/material-ui/src/Box/Box.test.js
mnajdova Oct 22, 2020
06ac444
Update packages/material-ui/src/Box/Box.test.js
mnajdova Oct 22, 2020
66d4e8e
prettier
mnajdova Oct 22, 2020
615cb47
changed box examples and improved docs
mnajdova Oct 22, 2020
783ff53
restructure a bit the docs page for the Box
mnajdova Oct 23, 2020
874d781
comma removed
mnajdova Oct 23, 2020
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
17 changes: 14 additions & 3 deletions packages/material-ui/src/Box/Box.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ function omit(input, fields) {
return output;
}

let warnedOnce = false;

/**
* @ignore - do not document.
*/
Expand All @@ -24,6 +26,17 @@ const BoxRoot = React.forwardRef(function StyledComponent(props, ref) {

const spread = omit(other, styleFunction.filterProps);

if (process.env.NODE_ENV !== 'production') {
if (!warnedOnce && Object.keys(spread).length !== Object.keys(other).length) {
warnedOnce = true;
console.warn(
'Material-UI: You are using deprecated props on the Box component.\n' +
'You should move the properties inside the `sx` prop. For example:\n' +
'<Box m={2} /> should become <Box sx={{ m: 2 }} />',
);
}
}

if (clone) {
return React.cloneElement(children, {
className: clsx(children.props.className, className),
Expand All @@ -49,11 +62,9 @@ BoxRoot.propTypes = {
component: PropTypes.elementType,
};

const shouldForwardProp = (prop) => styleFunction.filterProps.indexOf(prop) === -1;

/**
* @ignore - do not document.
*/
const Box = styled(BoxRoot, { shouldForwardProp }, { muiName: 'MuiBox' })(styleFunction);
const Box = styled(BoxRoot, {}, { muiName: 'MuiBox' })(styleFunction);

export default Box;
12 changes: 12 additions & 0 deletions packages/material-ui/src/Box/Box.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ describe('<Box />', () => {
</div>
);

it('warns if system props are used directly on the Box component', () => {
expect(() => {
render(
<Box
color="primary.main"
fontFamily="Comic Sans"
fontSize={{ xs: 'h6.fontSize', sm: 'h4.fontSize', md: 'h3.fontSize' }}
/>,
);
}).toWarnDev('Material-UI: You are using deprecated props on the Box component.\n');
});

it('renders children and box content', () => {
const { container, getByTestId } = render(
<Box component="span" m={1}>
Expand Down