Skip to content

Commit

Permalink
refactor(react-grid-material-ui): show the ResizingControl on the Cel…
Browse files Browse the repository at this point in the history
…l hover (DevExpress#735)
  • Loading branch information
MaximKudriavtsev authored Feb 9, 2018
1 parent 7dfc052 commit 1f13d84
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,27 @@ const styles = theme => ({
'&:first-child': {
paddingLeft: theme.spacing.unit * 3,
},
'&:hover $resizeHandleLine': {
opacity: 1,
},
},
resizeHandleLine: {
opacity: 0,
},
'@media (pointer: fine)': {
resizeHandleLine: {
opacity: 0,
},
resizeHandleActive: {
'& $resizeHandleLine': {
opacity: 1,
},
},
resizeHandle: {
'&:hover $resizeHandleLine': {
opacity: 1,
},
},
},
cellNoUserSelect: {
userSelect: 'none',
Expand Down Expand Up @@ -126,6 +147,7 @@ class TableHeaderCellBase extends React.PureComponent {
onWidthChange={onWidthChange}
onWidthDraft={onWidthDraft}
onWidthDraftCancel={onWidthDraftCancel}
resizeHandleOpacityClass={classes.resizeHandleLine}
/>
)}
</TableCell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,10 @@ const styles = theme => ({
},
resizeHandleActive: {
'& $resizeHandleLine': {
opacity: '1',
backgroundColor: theme.palette.primary[300],
},
},
'@media (pointer: fine)': {
resizeHandleLine: {
opacity: 0,
},
resizeHandleActive: {
'& $resizeHandleLine': {
opacity: 1,
},
},
resizeHandle: {
'&:hover $resizeHandleLine': {
opacity: 1,
},
},
},
});

export class ResizingControlBase extends React.PureComponent {
Expand All @@ -77,7 +63,7 @@ export class ResizingControlBase extends React.PureComponent {
};
}
render() {
const { classes } = this.props;
const { classes, resizeHandleOpacityClass } = this.props;
const { resizing } = this.state;

return (
Expand All @@ -94,12 +80,14 @@ export class ResizingControlBase extends React.PureComponent {
>
<div
className={classNames({
[resizeHandleOpacityClass]: true,
[classes.resizeHandleLine]: true,
[classes.resizeHandleFirstLine]: true,
})}
/>
<div
className={classNames({
[resizeHandleOpacityClass]: true,
[classes.resizeHandleLine]: true,
[classes.resizeHandleSecondLine]: true,
})}
Expand All @@ -115,6 +103,7 @@ ResizingControlBase.propTypes = {
onWidthDraft: PropTypes.func.isRequired,
onWidthDraftCancel: PropTypes.func.isRequired,
classes: PropTypes.object.isRequired,
resizeHandleOpacityClass: PropTypes.string.isRequired,
};

export const ResizingControl = withStyles(styles, { name: 'ResizingControl' })(ResizingControlBase);
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const defaultProps = {
onWidthChange: () => {},
onWidthDraft: () => {},
onWidthDraftCancel: () => {},
resizeHandleOpacityClass: 'test',
};

describe('ResizingControl', () => {
Expand Down

0 comments on commit 1f13d84

Please sign in to comment.