forked from jquense/react-big-calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: DnD support for custom DropWrapper components (dayWrapper and d…
…ateCellWrapper) (jquense#843) * Added DnD support for custom DateCellWrapper and DayWrapper components * Code cleanup Fixed all hardcoded `defaultView` prop strings to use the Views constants * Custom DropWrapper fixes - Pass through range and value props to match non-dnd component props - Added `customComponents` utility file for use with stories - Clarified comment in `withDragAndDrop`
- Loading branch information
Showing
10 changed files
with
163 additions
and
26 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
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
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
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,49 @@ | ||
import React from 'react' | ||
import { action } from '@storybook/react' | ||
|
||
const customComponents = { | ||
dateCellWrapper: dateCellWrapperProps => { | ||
// Show 'click me' text in arbitrary places by using the range prop | ||
const hasAlert = dateCellWrapperProps.range | ||
? dateCellWrapperProps.range.some(date => { | ||
return date.getDate() % 12 === 0 | ||
}) | ||
: false | ||
|
||
const style = { | ||
display: 'flex', | ||
flex: 1, | ||
borderLeft: '1px solid #DDD', | ||
backgroundColor: hasAlert ? '#f5f5dc' : '#fff', | ||
} | ||
return ( | ||
<div style={style}> | ||
{hasAlert && ( | ||
<a onClick={action('custom dateCellWrapper component clicked')}> | ||
Click me | ||
</a> | ||
)} | ||
{dateCellWrapperProps.children} | ||
</div> | ||
) | ||
}, | ||
dayWrapper: dayWrapperProps => { | ||
// Show different styles at arbitrary time | ||
const hasCustomInfo = dayWrapperProps.value | ||
? dayWrapperProps.value.getHours() === 4 | ||
: false | ||
const style = { | ||
display: 'flex', | ||
flex: 1, | ||
backgroundColor: hasCustomInfo ? '#f5f5dc' : '#fff', | ||
} | ||
return ( | ||
<div style={style}> | ||
{hasCustomInfo && 'Custom Day Wrapper'} | ||
{dayWrapperProps.children} | ||
</div> | ||
) | ||
}, | ||
} | ||
|
||
export default customComponents |