Skip to content

Commit da64fea

Browse files
committed
Merge remote-tracking branch 'upstream/next' into feat/sx-prop-docs-page
2 parents 6007e3b + a282900 commit da64fea

File tree

34 files changed

+816
-300
lines changed

34 files changed

+816
-300
lines changed

.circleci/config.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ defaults: &defaults
66
description: The dist-tag of react to be used
77
type: string
88
default: stable
9+
test-gate:
10+
description: A particular type of tests that should be run
11+
type: string
12+
default: undefined
913
environment:
1014
# expose it globally otherwise we have to thread it from each job to the install command
1115
REACT_DIST_TAG: << parameters.react-dist-tag >>
16+
TEST_GATE: << parameters.test-gate >>
1217
working_directory: /tmp/material-ui
1318
docker:
1419
- image: circleci/node:10
@@ -285,3 +290,16 @@ workflows:
285290
- next
286291
jobs:
287292
- test_types_next
293+
timezone-tests:
294+
triggers:
295+
- schedule:
296+
cron: '23 * * * *'
297+
filters:
298+
branches:
299+
only:
300+
- next
301+
jobs:
302+
- test_unit:
303+
test-gate: experimental-timezones
304+
- test_browser:
305+
test-gate: experimental-timezones

docs/src/pages/components/autocomplete/ComboBox.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import Autocomplete from '@material-ui/core/Autocomplete';
66
export default function ComboBox() {
77
return (
88
<Autocomplete
9+
disablePortal
910
id="combo-box-demo"
1011
options={top100Films}
1112
style={{ width: 300 }}
1213
renderInput={(params) => (
13-
<TextField {...params} label="Combo box" variant="outlined" />
14+
<TextField {...params} label="Movie" variant="outlined" />
1415
)}
1516
/>
1617
);

docs/src/pages/components/autocomplete/ComboBox.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import Autocomplete from '@material-ui/core/Autocomplete';
66
export default function ComboBox() {
77
return (
88
<Autocomplete
9+
disablePortal
910
id="combo-box-demo"
1011
options={top100Films}
1112
style={{ width: 300 }}
1213
renderInput={(params) => (
13-
<TextField {...params} label="Combo box" variant="outlined" />
14+
<TextField {...params} label="Movie" variant="outlined" />
1415
)}
1516
/>
1617
);

docs/src/pages/guides/migration-v4/migration-v4.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ You need to update your `package.json` to use the latest version of Material-UI.
2929

3030
```json
3131
"dependencies": {
32-
"@material-ui/core": "^5.0.0-alpha.1"
32+
"@material-ui/core": "^5.0.0"
3333
}
3434
```
3535

@@ -66,7 +66,7 @@ If you need to support IE 11, check out our [legacy bundle](/guides/minimizing-b
6666

6767
### non-ref-forwarding class components
6868

69-
Support for non-ref-forwarding class components in the `component` prop or as an immediate `children` has been dropped. If you were using `unstable_createStrictModeTheme` or didn't see any warnings related to `findDOMNode` in `React.StrictMode` then you don't need to do anything.
69+
Support for non-ref-forwarding class components in the `component` prop or as immediate `children` has been dropped. If you were using `unstable_createStrictModeTheme` or didn't see any warnings related to `findDOMNode` in `React.StrictMode` then you don't need to do anything.
7070
Otherwise check out the ["Caveat with refs" section in our composition guide](/guides/composition/#caveat-with-refs) to find out how to migrate.
7171
This change affects almost all components where you're using the `component` prop or passing `children` to components that require `children` to be elements (e.g. `<MenuList><CustomMenuItem /></MenuList>`)
7272

@@ -331,6 +331,17 @@ const classes = makeStyles(theme => ({
331331
+<BottomNavigation onChange={(event: React.SyntheticEvent) => {}} />
332332
```
333333

334+
### Box
335+
336+
- The system props have been deprecated in v5, and replaced with the `sx` prop.
337+
338+
```diff
339+
-<Box border="1px dashed grey" p={[2, 3, 4]} m={2}>
340+
+<Box sx={{ border: "1px dashed grey", p: [2, 3, 4], m: 2 }}>
341+
```
342+
343+
[This codemod](https://github.com/mui-org/material-ui/tree/next/packages/material-ui-codemod#box-sx-prop) will automatically update your code to the new syntax.
344+
334345
### Button
335346

336347
- The button `color` prop is now "primary" by default, and "default" has been removed. This makes the button closer to the Material Design specification and simplifies the API.

docs/src/pages/system/properties/properties.md

Lines changed: 56 additions & 55 deletions
Large diffs are not rendered by default.

docs/src/pages/system/typography/typography.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,13 @@
7777
import { typography } from '@material-ui/system';
7878
```
7979

80-
| Import name | Prop | CSS property | Theme key |
81-
| :-------------- | :-------------- | :--------------- | :--------------------------------------------------------------------- |
82-
| `fontFamily` | `fontFamily` | `font-family` | [`typography`](/customization/default-theme/?expand-path=$.typography) |
83-
| `fontSize` | `fontSize` | `font-size` | [`typography`](/customization/default-theme/?expand-path=$.typography) |
84-
| `fontStyle` | `fontStyle` | `font-style` | [`typography`](/customization/default-theme/?expand-path=$.typography) |
85-
| `fontWeight` | `fontWeight` | `font-weight` | [`typography`](/customization/default-theme/?expand-path=$.typography) |
86-
| `letterSpacing` | `letterSpacing` | `letter-spacing` | none |
87-
| `lineHeight` | `lineHeight` | `line-height` | none |
88-
| `textAlign` | `textAlign` | `text-align` | none |
80+
| Import name | Prop | CSS property | Theme key |
81+
| :-------------- | :-------------- | :------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------- |
82+
| `typography` | `typography` | `font-family`, `font-weight`, `font-size`, `line-height`, `letter-spacing`, `text-transform` | [`typography`](/customization/default-theme/?expand-path=$.typography) |
83+
| `fontFamily` | `fontFamily` | `font-family` | [`typography`](/customization/default-theme/?expand-path=$.typography) |
84+
| `fontSize` | `fontSize` | `font-size` | [`typography`](/customization/default-theme/?expand-path=$.typography) |
85+
| `fontStyle` | `fontStyle` | `font-style` | [`typography`](/customization/default-theme/?expand-path=$.typography) |
86+
| `fontWeight` | `fontWeight` | `font-weight` | [`typography`](/customization/default-theme/?expand-path=$.typography) |
87+
| `letterSpacing` | `letterSpacing` | `letter-spacing` | none |
88+
| `lineHeight` | `lineHeight` | `line-height` | none |
89+
| `textAlign` | `textAlign` | `text-align` | none |

packages/material-ui-codemod/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,23 @@ APIs.
1818

1919
## Included Scripts
2020

21+
### v5.0.0
22+
23+
#### `box-sx-prop`
24+
25+
Updates the Box API from separate system props to `sx`.
26+
27+
The diff should look like this:
28+
29+
```diff
30+
-<Box border="1px dashed grey" p={[2, 3, 4]} m={2}>
31+
+<Box sx={{ border: "1px dashed grey", p: [2, 3, 4], m: 2 }}>
32+
```
33+
34+
```sh
35+
find src -name '*.js' -print | xargs npx jscodeshift -t node_modules/@material-ui/codemod/lib/v5.0.0/box-sx-prop.js
36+
```
37+
2138
### v4.0.0
2239

2340
#### `theme-spacing-api`
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
const boxProps = [
2+
'border',
3+
'borderTop',
4+
'borderRight',
5+
'borderBottom',
6+
'borderLeft',
7+
'borderColor',
8+
'borderRadius',
9+
'displayPrint',
10+
'display',
11+
'overflow',
12+
'textOverflow',
13+
'visibility',
14+
'whiteSpace',
15+
'flexDirection',
16+
'flexWrap',
17+
'justifyContent',
18+
'alignItems',
19+
'alignContent',
20+
'order',
21+
'flex',
22+
'flexGrow',
23+
'flexShrink',
24+
'alignSelf',
25+
'color',
26+
'bgcolor',
27+
'position',
28+
'zIndex',
29+
'top',
30+
'right',
31+
'bottom',
32+
'left',
33+
'boxShadow',
34+
'width',
35+
'maxWidth',
36+
'minWidth',
37+
'height',
38+
'maxHeight',
39+
'minHeight',
40+
'boxSizing',
41+
'm',
42+
'mt',
43+
'mr',
44+
'mb',
45+
'ml',
46+
'mx',
47+
'my',
48+
'p',
49+
'pt',
50+
'pr',
51+
'pb',
52+
'pl',
53+
'px',
54+
'py',
55+
'margin',
56+
'marginTop',
57+
'marginRight',
58+
'marginBottom',
59+
'marginLeft',
60+
'marginX',
61+
'marginY',
62+
'padding',
63+
'paddingTop',
64+
'paddingRight',
65+
'paddingBottom',
66+
'paddingLeft',
67+
'paddingX',
68+
'paddingY',
69+
'fontFamily',
70+
'fontSize',
71+
'fontStyle',
72+
'fontWeight',
73+
'letterSpacing',
74+
'lineHeight',
75+
'textAlign',
76+
];
77+
78+
export default function transformer(file, api) {
79+
const j = api.jscodeshift;
80+
81+
function buildSxValue(node, value) {
82+
value.push(
83+
j.objectProperty(
84+
j.identifier(node.name.name),
85+
node.value.expression ? node.value.expression : node.value,
86+
false,
87+
false,
88+
),
89+
);
90+
return value;
91+
}
92+
93+
return j(file.source)
94+
.findJSXElements('Box')
95+
.forEach((path) => {
96+
let sxValue = [];
97+
const attributes = path.node.openingElement.attributes;
98+
attributes.forEach((node, index) => {
99+
// Only transform whitelisted props
100+
if (boxProps.includes(node.name.name)) {
101+
sxValue = buildSxValue(node, sxValue);
102+
delete attributes[index];
103+
}
104+
});
105+
if (sxValue.length > 0) {
106+
attributes.push(
107+
j.jsxAttribute(
108+
j.jsxIdentifier('sx'),
109+
j.jsxExpressionContainer(j.objectExpression(sxValue)),
110+
),
111+
);
112+
}
113+
})
114+
.toSource();
115+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
import { expect } from 'chai';
4+
import jscodeshift from 'jscodeshift';
5+
import transform from './box-sx-prop';
6+
7+
function read(fileName) {
8+
return fs.readFileSync(path.join(__dirname, fileName), 'utf8').toString();
9+
}
10+
11+
describe('@material-ui/codemod', () => {
12+
describe('v5.0.0', () => {
13+
describe('box-sx-prop', () => {
14+
it('transforms props as needed', () => {
15+
const actual = transform(
16+
{
17+
source: read('./box-sx-prop.test/actual.js'),
18+
path: require.resolve('./box-sx-prop.test/actual.js'),
19+
},
20+
{ jscodeshift: jscodeshift },
21+
{},
22+
);
23+
24+
const expected = read('./box-sx-prop.test/expected.js');
25+
expect(actual).to.equal(expected, 'The transformed version should be correct');
26+
});
27+
28+
it('should be idempotent', () => {
29+
const actual = transform(
30+
{
31+
source: read('./box-sx-prop.test/expected.js'),
32+
path: require.resolve('./box-sx-prop.test/expected.js'),
33+
},
34+
{ jscodeshift: jscodeshift },
35+
{},
36+
);
37+
38+
const expected = read('./box-sx-prop.test/expected.js');
39+
expect(actual).to.equal(expected, 'The transformed version should be correct');
40+
});
41+
});
42+
});
43+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as React from 'react';
2+
import Box from '@material-ui/core/Box';
3+
import Button from '@material-ui/core/Button';
4+
5+
export default function BoxComponent() {
6+
return (
7+
<Box border="1px dashed grey" p={[2, 3, 4]}>
8+
<Box component="span" clone p={{ xs: 2, sm: 3, md: 4 }} m={2} border="1px dashed grey">
9+
<Button component="span">Save</Button>
10+
</Box>
11+
</Box>
12+
);
13+
}

0 commit comments

Comments
 (0)