Skip to content

Commit

Permalink
[ButtonGroup] Add orientation prop (#18762)
Browse files Browse the repository at this point in the history
  • Loading branch information
SandraMarcelaHerreraArriaga authored and oliviertassinari committed Dec 12, 2019
1 parent a8cd858 commit 6fb06f9
Show file tree
Hide file tree
Showing 11 changed files with 278 additions and 228 deletions.
12 changes: 11 additions & 1 deletion docs/pages/api/button-group.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ You can learn more about the difference by [reading this guide](/guides/minimizi
| <span class="prop-name">disableFocusRipple</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the button keyboard focus ripple will be disabled. `disableRipple` must also be true. |
| <span class="prop-name">disableRipple</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the button ripple effect will be disabled. |
| <span class="prop-name">fullWidth</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the buttons will take up the full width of its container. |
| <span class="prop-name">orientation</span> | <span class="prop-type">'vertical'<br>&#124;&nbsp;'horizontal'</span> | <span class="prop-default">'horizontal'</span> | The group orientation. |
| <span class="prop-name">size</span> | <span class="prop-type">'small'<br>&#124;&nbsp;'medium'<br>&#124;&nbsp;'large'</span> | <span class="prop-default">'medium'</span> | The size of the button. `small` is equivalent to the dense button styling. |
| <span class="prop-name">variant</span> | <span class="prop-type">'text'<br>&#124;&nbsp;'outlined'<br>&#124;&nbsp;'contained'</span> | <span class="prop-default">'outlined'</span> | The variant to use. |

Expand All @@ -48,18 +49,27 @@ Any other props supplied will be provided to the root element (native element).
|:-----|:-------------|:------------|
| <span class="prop-name">root</span> | <span class="prop-name">.MuiButtonGroup-root</span> | Styles applied to the root element.
| <span class="prop-name">contained</span> | <span class="prop-name">.MuiButtonGroup-contained</span> | Styles applied to the root element if `variant="contained"`.
| <span class="prop-name">disabled</span> | <span class="prop-name">.Mui-disabled</span> | Pseudo-class applied to child elements if `disabled={true}`.
| <span class="prop-name">fullWidth</span> | <span class="prop-name">.MuiButtonGroup-fullWidth</span> | Styles applied to the root element if `fullWidth={true}`.
| <span class="prop-name">vertical</span> | <span class="prop-name">.MuiButtonGroup-vertical</span> | Styles applied to the root element if `orientation="vertical"`.
| <span class="prop-name">grouped</span> | <span class="prop-name">.MuiButtonGroup-grouped</span> | Styles applied to the children.
| <span class="prop-name">groupedHorizontal</span> | <span class="prop-name">.MuiButtonGroup-groupedHorizontal</span> | Styles applied to the children if `orientation="horizontal"`.
| <span class="prop-name">groupedVertical</span> | <span class="prop-name">.MuiButtonGroup-groupedVertical</span> | Styles applied to the children if `orientation="vertical"`.
| <span class="prop-name">groupedText</span> | <span class="prop-name">.MuiButtonGroup-groupedText</span> | Styles applied to the children if `variant="text"`.
| <span class="prop-name">groupedTextHorizontal</span> | <span class="prop-name">.MuiButtonGroup-groupedTextHorizontal</span> | Styles applied to the children if `variant="text"` and `orientation="horizontal"`.
| <span class="prop-name">groupedTextVertical</span> | <span class="prop-name">.MuiButtonGroup-groupedTextVertical</span> | Styles applied to the children if `variant="text"` and `orientation="vertical"`.
| <span class="prop-name">groupedTextPrimary</span> | <span class="prop-name">.MuiButtonGroup-groupedTextPrimary</span> | Styles applied to the children if `variant="text"` and `color="primary"`.
| <span class="prop-name">groupedTextSecondary</span> | <span class="prop-name">.MuiButtonGroup-groupedTextSecondary</span> | Styles applied to the children if `variant="text"` and `color="secondary"`.
| <span class="prop-name">groupedOutlined</span> | <span class="prop-name">.MuiButtonGroup-groupedOutlined</span> | Styles applied to the children if `variant="outlined"`.
| <span class="prop-name">groupedOutlinedHorizontal</span> | <span class="prop-name">.MuiButtonGroup-groupedOutlinedHorizontal</span> | Styles applied to the children if `variant="outlined"` and `orientation="horizontal"`.
| <span class="prop-name">groupedOutlinedVertical</span> | <span class="prop-name">.MuiButtonGroup-groupedOutlinedVertical</span> | Styles applied to the children if `variant="outlined"` and `orientation="vertical"`.
| <span class="prop-name">groupedOutlinedPrimary</span> | <span class="prop-name">.MuiButtonGroup-groupedOutlinedPrimary</span> | Styles applied to the children if `variant="outlined"` and `color="primary"`.
| <span class="prop-name">groupedOutlinedSecondary</span> | <span class="prop-name">.MuiButtonGroup-groupedOutlinedSecondary</span> | Styles applied to the children if `variant="outlined"` and `color="secondary"`.
| <span class="prop-name">groupedContained</span> | <span class="prop-name">.MuiButtonGroup-groupedContained</span> | Styles applied to the children if `variant="contained"`.
| <span class="prop-name">groupedContainedHorizontal</span> | <span class="prop-name">.MuiButtonGroup-groupedContainedHorizontal</span> | Styles applied to the children if `variant="contained"` and `orientation="horizontal"`.
| <span class="prop-name">groupedContainedVertical</span> | <span class="prop-name">.MuiButtonGroup-groupedContainedVertical</span> | Styles applied to the children if `variant="contained"` and `orientation="vertical"`.
| <span class="prop-name">groupedContainedPrimary</span> | <span class="prop-name">.MuiButtonGroup-groupedContainedPrimary</span> | Styles applied to the children if `variant="contained"` and `color="primary"`.
| <span class="prop-name">groupedContainedSecondary</span> | <span class="prop-name">.MuiButtonGroup-groupedContainedSecondary</span> | Styles applied to the children if `variant="contained"` and `color="secondary"`.
| <span class="prop-name">disabled</span> | <span class="prop-name">.Mui-disabled</span> | Pseudo-class applied to child elements if `disabled={true}`.

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

Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/Demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ function Demo(props) {
!demoOptions.hideHeader &&
demoOptions.defaultCodeOpen !== false &&
jsx !== demoData.raw &&
jsx.split(/\n/).length <= 15;
jsx.split(/\n/).length <= 16;

let showCodeLabel;
if (codeOpen) {
Expand Down
17 changes: 17 additions & 0 deletions docs/src/pages/components/buttons/GroupOrientation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import Button from '@material-ui/core/Button';
import ButtonGroup from '@material-ui/core/ButtonGroup';

export default function GroupOrientation() {
return (
<ButtonGroup
orientation="vertical"
color="primary"
aria-label="vertical outlined primary button group"
>
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
);
}
17 changes: 17 additions & 0 deletions docs/src/pages/components/buttons/GroupOrientation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import Button from '@material-ui/core/Button';
import ButtonGroup from '@material-ui/core/ButtonGroup';

export default function GroupOrientation() {
return (
<ButtonGroup
orientation="vertical"
color="primary"
aria-label="vertical outlined primary button group"
>
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
);
}
39 changes: 39 additions & 0 deletions docs/src/pages/components/buttons/GroupSizesColors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import Button from '@material-ui/core/Button';
import ButtonGroup from '@material-ui/core/ButtonGroup';
import { makeStyles } from '@material-ui/core/styles';

const useStyles = makeStyles(theme => ({
root: {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
'& > *': {
margin: theme.spacing(1),
},
},
}));

export default function GroupSizesColors() {
const classes = useStyles();

return (
<div className={classes.root}>
<ButtonGroup size="small" aria-label="small outlined button group">
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
<ButtonGroup color="secondary" aria-label="outlined secondary button group">
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
<ButtonGroup size="large" color="primary" aria-label="large outlined primary button group">
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
</div>
);
}
41 changes: 41 additions & 0 deletions docs/src/pages/components/buttons/GroupSizesColors.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from 'react';
import Button from '@material-ui/core/Button';
import ButtonGroup from '@material-ui/core/ButtonGroup';
import { makeStyles, createStyles, Theme } from '@material-ui/core/styles';

const useStyles = makeStyles((theme: Theme) =>
createStyles({
root: {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
'& > *': {
margin: theme.spacing(1),
},
},
}),
);

export default function GroupSizesColors() {
const classes = useStyles();

return (
<div className={classes.root}>
<ButtonGroup size="small" aria-label="small outlined button group">
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
<ButtonGroup color="secondary" aria-label="outlined secondary button group">
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
<ButtonGroup size="large" color="primary" aria-label="large outlined primary button group">
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
</div>
);
}
138 changes: 31 additions & 107 deletions docs/src/pages/components/buttons/GroupedButtons.js
Original file line number Diff line number Diff line change
@@ -1,115 +1,39 @@
import React from 'react';
import Grid from '@material-ui/core/Grid';
import Button from '@material-ui/core/Button';
import ButtonGroup from '@material-ui/core/ButtonGroup';
import { makeStyles } from '@material-ui/core/styles';

const useStyles = makeStyles(theme => ({
root: {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
'& > *': {
margin: theme.spacing(1),
},
},
}));

export default function GroupedButtons() {
const classes = useStyles();

return (
<Grid container spacing={3}>
<Grid item xs={12} md={6}>
<Grid container spacing={1} direction="column" alignItems="center">
<Grid item>
<ButtonGroup size="small" aria-label="small outlined button group">
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
</Grid>
<Grid item>
<ButtonGroup color="primary" aria-label="outlined primary button group">
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
</Grid>
<Grid item>
<ButtonGroup
color="secondary"
size="large"
aria-label="large outlined secondary button group"
>
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
</Grid>
</Grid>
</Grid>
<Grid item xs={12} md={6}>
<Grid container spacing={1} direction="column" alignItems="center">
<Grid item>
<ButtonGroup variant="contained" size="small" aria-label="small contained button group">
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
</Grid>
<Grid item>
<ButtonGroup
variant="contained"
color="primary"
aria-label="full-width contained primary button group"
>
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
</Grid>
<Grid item>
<ButtonGroup
variant="contained"
color="secondary"
size="large"
aria-label="large contained secondary button group"
>
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
</Grid>
</Grid>
</Grid>
<Grid item xs={12} md={6}>
<Grid container spacing={1} direction="column" alignItems="center">
<Grid item>
<ButtonGroup variant="text" size="small" aria-label="small contained button group">
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
</Grid>
<Grid item>
<ButtonGroup
variant="text"
color="primary"
aria-label="full-width contained primary button group"
>
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
</Grid>
<Grid item>
<ButtonGroup
variant="text"
color="secondary"
size="large"
aria-label="large contained secondary button group"
>
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
</Grid>
</Grid>
</Grid>
<Grid item xs={12} md={6}>
<ButtonGroup fullWidth aria-label="full width outlined button group">
<Button>Full</Button>
<Button>width</Button>
<Button>Group</Button>
</ButtonGroup>
</Grid>
</Grid>
<div className={classes.root}>
<ButtonGroup color="primary" aria-label="outlined primary button group">
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
<ButtonGroup variant="contained" color="primary" aria-label="contained primary button group">
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
<ButtonGroup variant="text" color="primary" aria-label="text primary button group">
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
</div>
);
}
Loading

0 comments on commit 6fb06f9

Please sign in to comment.