-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react-scheduler): allow appointment resizing (#1932)
- Loading branch information
1 parent
7fdf293
commit 785f8a1
Showing
31 changed files
with
1,114 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/dx-react-scheduler-material-ui/src/templates/appointment/appointment-container.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import * as React from 'react'; | ||
import * as PropTypes from 'prop-types'; | ||
|
||
export const AppointmentContainer = ({ style, children, ...restProps }) => ( | ||
<div | ||
style={style} | ||
{...restProps} | ||
> | ||
{children} | ||
</div> | ||
); | ||
|
||
AppointmentContainer.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
style: PropTypes.object.isRequired, | ||
}; |
31 changes: 31 additions & 0 deletions
31
...s/dx-react-scheduler-material-ui/src/templates/appointment/appointment-container.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import * as React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { AppointmentContainer } from './appointment-container'; | ||
|
||
describe('Appointments', () => { | ||
const defaultProps = { | ||
style: {}, | ||
}; | ||
describe('AppointmentContainer', () => { | ||
it('should pass rest props to the root element', () => { | ||
const tree = shallow(( | ||
<AppointmentContainer {...defaultProps} className="custom-class"> | ||
<div /> | ||
</AppointmentContainer> | ||
)); | ||
|
||
expect(tree.find('.custom-class')) | ||
.toBeTruthy(); | ||
}); | ||
it('should render children inside', () => { | ||
const tree = shallow(( | ||
<AppointmentContainer {...defaultProps} data={{ a: 1 }}> | ||
<div className="child" /> | ||
</AppointmentContainer> | ||
)); | ||
|
||
expect(tree.find('.child').exists()) | ||
.toBeTruthy(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
packages/dx-react-scheduler-material-ui/src/templates/appointment/split-indicator.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import * as React from 'react'; | ||
import * as PropTypes from 'prop-types'; | ||
import classNames from 'classnames'; | ||
import { withStyles } from '@material-ui/core/styles'; | ||
import { | ||
VERTICAL_TYPE, HORIZONTAL_TYPE, | ||
POSITION_START, POSITION_END, | ||
} from '@devexpress/dx-scheduler-core'; | ||
|
||
const verticalStyles = { | ||
width: '100%', | ||
height: '10px', | ||
}; | ||
|
||
const horizontalStyles = { | ||
top: 0, | ||
width: '10px', | ||
height: '100%', | ||
}; | ||
|
||
const styles = { | ||
slice: { | ||
position: 'absolute', | ||
zIndex: 50, | ||
}, | ||
verticalStart: { | ||
...verticalStyles, | ||
top: '-10px', | ||
boxShadow: '0 10px 15px rgba(0,0,0,0.2)', | ||
}, | ||
verticalEnd: { | ||
...verticalStyles, | ||
bottom: '-10px', | ||
boxShadow: '0 -10px 15px rgba(0,0,0,0.2)', | ||
}, | ||
horizontalStart: { | ||
...horizontalStyles, | ||
left: '-10px', | ||
boxShadow: '10px 0 15px rgba(0,0,0,0.2)', | ||
}, | ||
horizontalEnd: { | ||
...horizontalStyles, | ||
right: '-10px', | ||
boxShadow: '-10px 0 15px rgba(0,0,0,0.2)', | ||
}, | ||
}; | ||
|
||
const SplitIndicatorBase = ({ | ||
position, appointmentType, classes, className, ...restProps | ||
}) => { | ||
const vertical = appointmentType === VERTICAL_TYPE; | ||
const start = position === POSITION_START; | ||
return ( | ||
<div | ||
className={classNames({ | ||
[classes.slice]: true, | ||
[classes.verticalStart]: vertical && start, | ||
[classes.verticalEnd]: vertical && !start, | ||
[classes.horizontalStart]: !vertical && start, | ||
[classes.horizontalEnd]: !vertical && !start, | ||
}, className)} | ||
{...restProps} | ||
/> | ||
); | ||
}; | ||
|
||
SplitIndicatorBase.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
appointmentType: PropTypes.oneOf([VERTICAL_TYPE, HORIZONTAL_TYPE]).isRequired, | ||
position: PropTypes.oneOf([POSITION_START, POSITION_END]).isRequired, | ||
className: PropTypes.string, | ||
}; | ||
|
||
SplitIndicatorBase.defaultProps = { | ||
className: undefined, | ||
}; | ||
|
||
export const SplitIndicator = withStyles(styles, { name: 'AppointmentsContainer' })(SplitIndicatorBase); |
60 changes: 60 additions & 0 deletions
60
packages/dx-react-scheduler-material-ui/src/templates/appointment/split-indicator.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import * as React from 'react'; | ||
import { createShallow, getClasses } from '@material-ui/core/test-utils'; | ||
import { SplitIndicator } from './split-indicator'; | ||
|
||
describe('Appointment', () => { | ||
const defaultProps = { | ||
position: 'start', | ||
appointmentType: 'vertical', | ||
}; | ||
describe('SplitIndicator', () => { | ||
let shallow; | ||
let classes; | ||
beforeAll(() => { | ||
classes = getClasses(<SplitIndicator {...defaultProps} />); | ||
shallow = createShallow({ dive: true }); | ||
}); | ||
it('should pass rest props to the root element', () => { | ||
const tree = shallow(( | ||
<SplitIndicator {...defaultProps} a={{ a: 1 }} /> | ||
)); | ||
|
||
expect(tree.props().a) | ||
.toMatchObject({ a: 1 }); | ||
}); | ||
it('should pass className', () => { | ||
const tree = shallow(( | ||
<SplitIndicator {...defaultProps} className="custom-class" /> | ||
)); | ||
|
||
expect(tree.is('.custom-class')) | ||
.toBeTruthy(); | ||
expect(tree.is(`.${classes.slice}`)) | ||
.toBeTruthy(); | ||
expect(tree.is(`.${classes.verticalStart}`)) | ||
.toBeTruthy(); | ||
}); | ||
it('should manage classes by props', () => { | ||
let tree = shallow(( | ||
<SplitIndicator position="start" appointmentType="horizontal" /> | ||
)); | ||
|
||
expect(tree.is(`.${classes.horizontalStart}`)) | ||
.toBeTruthy(); | ||
|
||
tree = shallow(( | ||
<SplitIndicator position="end" appointmentType="horizontal" /> | ||
)); | ||
|
||
expect(tree.is(`.${classes.horizontalEnd}`)) | ||
.toBeTruthy(); | ||
|
||
tree = shallow(( | ||
<SplitIndicator position="end" appointmentType="vertical" /> | ||
)); | ||
|
||
expect(tree.is(`.${classes.verticalEnd}`)) | ||
.toBeTruthy(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.