Skip to content

Commit

Permalink
[Divider] Add vertical support
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Aug 17, 2019
1 parent e5b4aa0 commit 57c8781
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
3 changes: 1 addition & 2 deletions docs/src/pages/components/text-fields/CustomizedInputBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const useStyles = makeStyles({
padding: 10,
},
divider: {
width: 1,
height: 28,
margin: 4,
},
Expand All @@ -45,7 +44,7 @@ export default function CustomizedInputBase() {
<IconButton className={classes.iconButton} aria-label="search">
<SearchIcon />
</IconButton>
<Divider className={classes.divider} />
<Divider className={classes.divider} orientation="vertical" />
<IconButton color="primary" className={classes.iconButton} aria-label="directions">
<DirectionsIcon />
</IconButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const useStyles = makeStyles({
padding: 10,
},
divider: {
width: 1,
height: 28,
margin: 4,
},
Expand All @@ -45,7 +44,7 @@ export default function CustomizedInputBase() {
<IconButton className={classes.iconButton} aria-label="search">
<SearchIcon />
</IconButton>
<Divider className={classes.divider} />
<Divider className={classes.divider} orientation="vertical" />
<IconButton color="primary" className={classes.iconButton} aria-label="directions">
<DirectionsIcon />
</IconButton>
Expand Down
3 changes: 2 additions & 1 deletion packages/material-ui/src/Divider/Divider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ declare const Divider: OverridableComponent<{
props: {
absolute?: boolean;
light?: boolean;
orientation?: 'horizontal' | 'vertical';
variant?: 'fullWidth' | 'inset' | 'middle';
};
defaultComponent: 'hr';
classKey: DividerClassKey;
}>;

export type DividerClassKey = 'root' | 'absolute' | 'inset' | 'light' | 'middle';
export type DividerClassKey = 'root' | 'absolute' | 'inset' | 'light' | 'middle' | 'vertical';

export type DividerProps = SimplifiedPropsOf<typeof Divider>;

Expand Down
14 changes: 12 additions & 2 deletions packages/material-ui/src/Divider/Divider.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ export const styles = theme => ({
marginLeft: theme.spacing(2),
marginRight: theme.spacing(2),
},
/* Styles applied to the root element if `orientation="vertical"`. */
vertical: {
height: '100%',
width: 1,
},
});

const Divider = React.forwardRef(function Divider(props, ref) {
Expand All @@ -42,6 +47,7 @@ const Divider = React.forwardRef(function Divider(props, ref) {
className,
component: Component = 'hr',
light = false,
orientation = 'horizontal',
role = Component !== 'hr' ? 'separator' : undefined,
variant = 'fullWidth',
...other
Expand All @@ -52,10 +58,10 @@ const Divider = React.forwardRef(function Divider(props, ref) {
className={clsx(
classes.root,
{
[classes.inset]: variant === 'inset',
[classes.middle]: variant === 'middle',
[classes[variant]]: variant !== 'fullWidth',
[classes.absolute]: absolute,
[classes.light]: light,
[classes.vertical]: orientation === 'vertical',
},
className,
)}
Expand Down Expand Up @@ -89,6 +95,10 @@ Divider.propTypes = {
* If `true`, the divider will have a lighter color.
*/
light: PropTypes.bool,
/**
* The divider orientation.
*/
orientation: PropTypes.oneOf(['horizontal', 'vertical']),
/**
* @ignore
*/
Expand Down

0 comments on commit 57c8781

Please sign in to comment.