Skip to content

Commit

Permalink
Merge branch 'next' into batch-small-changes-v25
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari authored Jul 26, 2020
2 parents bf2f723 + 557c4ad commit 30b8145
Show file tree
Hide file tree
Showing 17 changed files with 253 additions and 160 deletions.
5 changes: 3 additions & 2 deletions docs/pages/api-docs/accordion.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ Any other props supplied will be provided to the root element ([Paper](/api/pape
|:-----|:-------------|:------------|
| <span class="prop-name">root</span> | <span class="prop-name">.MuiAccordion-root</span> | Styles applied to the root element.
| <span class="prop-name">rounded</span> | <span class="prop-name">.MuiAccordion-rounded</span> | Styles applied to the root element if `square={false}`.
| <span class="prop-name">expanded</span> | <span class="prop-name">.Mui-expanded</span> | Styles applied to the root element if `expanded={true}`.
| <span class="prop-name">disabled</span> | <span class="prop-name">.Mui-disabled</span> | Styles applied to the root element if `disabled={true}`.
| <span class="prop-name">expanded</span> | <span class="prop-name">.Mui-expanded</span> | Pseudo-class applied to the root element if `expanded={true}`.
| <span class="prop-name">disabled</span> | <span class="prop-name">.Mui-disabled</span> | Pseudo-class applied to the root element if `disabled={true}`.
| <span class="prop-name">region</span> | <span class="prop-name">.MuiAccordion-region</span> | Styles applied to the region element, the container of the children.

You can override the style of the component thanks to one of these customization points:

Expand Down
6 changes: 3 additions & 3 deletions docs/pages/api-docs/collapse.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ Any other props supplied will be provided to the root element ([Transition](http

| Rule name | Global class | Description |
|:-----|:-------------|:------------|
| <span class="prop-name">container</span> | <span class="prop-name">.MuiCollapse-container</span> | Styles applied to the container element.
| <span class="prop-name">root</span> | <span class="prop-name">.MuiCollapse-root</span> | Styles applied to the root element.
| <span class="prop-name">horizontal</span> | <span class="prop-name">.MuiCollapse-horizontal</span> | Pseudo-class applied to the root element if `orientation="horizontal"`.
| <span class="prop-name">entered</span> | <span class="prop-name">.MuiCollapse-entered</span> | Styles applied to the container element when the transition has entered.
| <span class="prop-name">hidden</span> | <span class="prop-name">.MuiCollapse-hidden</span> | Styles applied to the container element when the transition has exited and `collapsedSize` != 0px.
| <span class="prop-name">entered</span> | <span class="prop-name">.MuiCollapse-entered</span> | Styles applied to the root element when the transition has entered.
| <span class="prop-name">hidden</span> | <span class="prop-name">.MuiCollapse-hidden</span> | Styles applied to the root element when the transition has exited and `collapsedSize` != 0px.
| <span class="prop-name">wrapper</span> | <span class="prop-name">.MuiCollapse-wrapper</span> | Styles applied to the outer wrapper element.
| <span class="prop-name">wrapperInner</span> | <span class="prop-name">.MuiCollapse-wrapperInner</span> | Styles applied to the inner wrapper element.

Expand Down
9 changes: 8 additions & 1 deletion docs/src/pages/components/snackbars/CustomizedSnackbars.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const useStyles = makeStyles((theme) => ({
marginTop: theme.spacing(2),
},
},
alert: {
width: '100%',
},
}));

export default function CustomizedSnackbars() {
Expand All @@ -39,7 +42,11 @@ export default function CustomizedSnackbars() {
Open success snackbar
</Button>
<Snackbar open={open} autoHideDuration={6000} onClose={handleClose}>
<Alert onClose={handleClose} severity="success">
<Alert
onClose={handleClose}
severity="success"
className={classes.alert}
>
This is a success message!
</Alert>
</Snackbar>
Expand Down
9 changes: 8 additions & 1 deletion docs/src/pages/components/snackbars/CustomizedSnackbars.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const useStyles = makeStyles((theme: Theme) => ({
marginTop: theme.spacing(2),
},
},
alert: {
width: '100%',
},
}));

export default function CustomizedSnackbars() {
Expand All @@ -39,7 +42,11 @@ export default function CustomizedSnackbars() {
Open success snackbar
</Button>
<Snackbar open={open} autoHideDuration={6000} onClose={handleClose}>
<Alert onClose={handleClose} severity="success">
<Alert
onClose={handleClose}
severity="success"
className={classes.alert}
>
This is a success message!
</Alert>
</Snackbar>
Expand Down
78 changes: 53 additions & 25 deletions docs/src/pages/components/tree-view/ControlledTreeView.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import TreeView from '@material-ui/lab/TreeView';
import Button from '@material-ui/core/Button';
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
import ChevronRightIcon from '@material-ui/icons/ChevronRight';
import TreeView from '@material-ui/lab/TreeView';
import TreeItem from '@material-ui/lab/TreeItem';

const useStyles = makeStyles({
const useStyles = makeStyles((theme) => ({
root: {
height: 216,
height: 270,
flexGrow: 1,
maxWidth: 400,
},
});
actions: {
marginBottom: theme.spacing(1),
},
}));

export default function ControlledTreeView() {
const classes = useStyles();
Expand All @@ -26,29 +30,53 @@ export default function ControlledTreeView() {
setSelected(nodeIds);
};

const handleExpandClick = () => {
setExpanded((oldExpanded) =>
oldExpanded.length === 0 ? ['1', '5', '6', '7'] : [],
);
};

const handleSelectClick = () => {
setSelected((oldSelected) =>
oldSelected.length === 0
? ['1', '2', '3', '4', '5', '6', '7', '8', '9']
: [],
);
};

return (
<TreeView
className={classes.root}
defaultCollapseIcon={<ExpandMoreIcon />}
defaultExpandIcon={<ChevronRightIcon />}
expanded={expanded}
selected={selected}
onNodeToggle={handleToggle}
onNodeSelect={handleSelect}
>
<TreeItem nodeId="1" label="Applications">
<TreeItem nodeId="2" label="Calendar" />
<TreeItem nodeId="3" label="Chrome" />
<TreeItem nodeId="4" label="Webstorm" />
</TreeItem>
<TreeItem nodeId="5" label="Documents">
<TreeItem nodeId="6" label="Material-UI">
<TreeItem nodeId="7" label="src">
<TreeItem nodeId="8" label="index.js" />
<TreeItem nodeId="9" label="tree-view.js" />
<div className={classes.root}>
<div className={classes.actions}>
<Button onClick={handleExpandClick}>
{expanded.length === 0 ? 'Expand all' : 'Collapse all'}
</Button>
<Button onClick={handleSelectClick}>
{selected.length === 0 ? 'Select all' : 'Unselect all'}
</Button>
</div>
<TreeView
defaultCollapseIcon={<ExpandMoreIcon />}
defaultExpandIcon={<ChevronRightIcon />}
expanded={expanded}
selected={selected}
onNodeToggle={handleToggle}
onNodeSelect={handleSelect}
multiSelect
>
<TreeItem nodeId="1" label="Applications">
<TreeItem nodeId="2" label="Calendar" />
<TreeItem nodeId="3" label="Chrome" />
<TreeItem nodeId="4" label="Webstorm" />
</TreeItem>
<TreeItem nodeId="5" label="Documents">
<TreeItem nodeId="6" label="Material-UI">
<TreeItem nodeId="7" label="src">
<TreeItem nodeId="8" label="index.js" />
<TreeItem nodeId="9" label="tree-view.js" />
</TreeItem>
</TreeItem>
</TreeItem>
</TreeItem>
</TreeView>
</TreeView>
</div>
);
}
90 changes: 60 additions & 30 deletions docs/src/pages/components/tree-view/ControlledTreeView.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import TreeView from '@material-ui/lab/TreeView';
import { makeStyles, createStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
import ChevronRightIcon from '@material-ui/icons/ChevronRight';
import TreeView from '@material-ui/lab/TreeView';
import TreeItem from '@material-ui/lab/TreeItem';

const useStyles = makeStyles({
root: {
height: 216,
flexGrow: 1,
maxWidth: 400,
},
});
const useStyles = makeStyles((theme) =>
createStyles({
root: {
height: 270,
flexGrow: 1,
maxWidth: 400,
},
actions: {
marginBottom: theme.spacing(1),
},
}),
);

export default function ControlledTreeView() {
const classes = useStyles();
Expand All @@ -26,29 +32,53 @@ export default function ControlledTreeView() {
setSelected(nodeIds);
};

const handleExpandClick = () => {
setExpanded((oldExpanded) =>
oldExpanded.length === 0 ? ['1', '5', '6', '7'] : [],
);
};

const handleSelectClick = () => {
setSelected((oldSelected) =>
oldSelected.length === 0
? ['1', '2', '3', '4', '5', '6', '7', '8', '9']
: [],
);
};

return (
<TreeView
className={classes.root}
defaultCollapseIcon={<ExpandMoreIcon />}
defaultExpandIcon={<ChevronRightIcon />}
expanded={expanded}
selected={selected}
onNodeToggle={handleToggle}
onNodeSelect={handleSelect}
>
<TreeItem nodeId="1" label="Applications">
<TreeItem nodeId="2" label="Calendar" />
<TreeItem nodeId="3" label="Chrome" />
<TreeItem nodeId="4" label="Webstorm" />
</TreeItem>
<TreeItem nodeId="5" label="Documents">
<TreeItem nodeId="6" label="Material-UI">
<TreeItem nodeId="7" label="src">
<TreeItem nodeId="8" label="index.js" />
<TreeItem nodeId="9" label="tree-view.js" />
<div className={classes.root}>
<div className={classes.actions}>
<Button onClick={handleExpandClick}>
{expanded.length === 0 ? 'Expand all' : 'Collapse all'}
</Button>
<Button onClick={handleSelectClick}>
{selected.length === 0 ? 'Select all' : 'Unselect all'}
</Button>
</div>
<TreeView
defaultCollapseIcon={<ExpandMoreIcon />}
defaultExpandIcon={<ChevronRightIcon />}
expanded={expanded}
selected={selected}
onNodeToggle={handleToggle}
onNodeSelect={handleSelect}
multiSelect
>
<TreeItem nodeId="1" label="Applications">
<TreeItem nodeId="2" label="Calendar" />
<TreeItem nodeId="3" label="Chrome" />
<TreeItem nodeId="4" label="Webstorm" />
</TreeItem>
<TreeItem nodeId="5" label="Documents">
<TreeItem nodeId="6" label="Material-UI">
<TreeItem nodeId="7" label="src">
<TreeItem nodeId="8" label="index.js" />
<TreeItem nodeId="9" label="tree-view.js" />
</TreeItem>
</TreeItem>
</TreeItem>
</TreeItem>
</TreeView>
</TreeView>
</div>
);
}
2 changes: 1 addition & 1 deletion docs/src/pages/components/tree-view/tree-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Tree views also support multi selection.

{{"demo": "pages/components/tree-view/MultiSelectTreeView.js"}}

### Controlled tree view
## Controlled tree view

The tree view also offers a controlled API.

Expand Down
7 changes: 7 additions & 0 deletions docs/src/pages/guides/migration-v4/migration-v4.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ This change affects almost all components where you're using the `component` pro
+<Collapse collapsedSize={40}>
```

- The `classes.container` key was changed to match the convention of the other components.

```diff
-<Collapse classes={{ container: 'collapse' }}>
+<Collapse classes={{ root: 'collapse' }}>
```

### Divider

- Use border instead of background color. It prevents inconsistent height on scaled screens. For people customizing the color of the border, the change requires changing the override CSS property:
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@rollup/plugin-replace": "^2.3.1",
"@testing-library/dom": "^7.0.3",
"@testing-library/react": "^10.0.1",
"@testing-library/react-hooks": "3.3.0",
"@testing-library/react-hooks": "3.4.1",
"@types/chai": "^4.2.3",
"@types/chai-dom": "^0.0.10",
"@types/enzyme": "^3.10.3",
Expand Down Expand Up @@ -95,7 +95,7 @@
"enzyme": "^3.9.0",
"enzyme-adapter-react-16": "^1.14.0",
"eslint": "^7.4.0",
"eslint-config-airbnb-typescript": "^8.0.2",
"eslint-config-airbnb-typescript": "^9.0.0",
"eslint-config-prettier": "^6.11.0",
"eslint-import-resolver-webpack": "^0.12.2",
"eslint-plugin-babel": "^5.3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Accordion/Accordion.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export interface AccordionProps extends StandardProps<PaperProps, AccordionClass
TransitionProps?: TransitionProps;
}

export type AccordionClassKey = 'root' | 'rounded' | 'expanded' | 'disabled';
export type AccordionClassKey = 'root' | 'rounded' | 'expanded' | 'disabled' | 'region';

/**
*
Expand Down
13 changes: 10 additions & 3 deletions packages/material-ui/src/Accordion/Accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ export const styles = (theme) => {
},
},
},
/* Styles applied to the root element if `expanded={true}`. */
/* Pseudo-class applied to the root element if `expanded={true}`. */
expanded: {},
/* Styles applied to the root element if `disabled={true}`. */
/* Pseudo-class applied to the root element if `disabled={true}`. */
disabled: {},
/* Styles applied to the region element, the container of the children. */
region: {},
};
};

Expand Down Expand Up @@ -137,7 +139,12 @@ const Accordion = React.forwardRef(function Accordion(props, ref) {
>
<AccordionContext.Provider value={contextValue}>{summary}</AccordionContext.Provider>
<TransitionComponent in={expanded} timeout="auto" {...TransitionProps}>
<div aria-labelledby={summary.props.id} id={summary.props['aria-controls']} role="region">
<div
aria-labelledby={summary.props.id}
id={summary.props['aria-controls']}
role="region"
className={classes.region}
>
{children}
</div>
</TransitionComponent>
Expand Down
8 changes: 7 additions & 1 deletion packages/material-ui/src/Collapse/Collapse.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ export interface CollapseProps extends StandardProps<TransitionProps, CollapseCl
timeout?: TransitionProps['timeout'] | 'auto';
}

export type CollapseClassKey = 'container' | 'entered' | 'hidden' | 'wrapper' | 'wrapperInner';
export type CollapseClassKey =
| 'root'
| 'horizontal'
| 'entered'
| 'hidden'
| 'wrapper'
| 'wrapperInner';

/**
* The Collapse transition is used by the
Expand Down
Loading

0 comments on commit 30b8145

Please sign in to comment.