Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timeGutterHeaderComponent #874

Merged
merged 4 commits into from
Jul 3, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/TimeGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ export default class TimeGrid extends Component {
eventComponent={components.event}
eventWrapperComponent={components.eventWrapper}
dateCellWrapperComponent={components.dateCellWrapper}
timeGutterHeaderComponent={components.timeGutterHeader}
onSelectSlot={this.handleSelectAllDaySlot}
onSelectEvent={this.handleSelectAlldayEvent}
onDoubleClickEvent={this.props.onDoubleClickEvent}
Expand Down
6 changes: 5 additions & 1 deletion src/TimeGridHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class TimeGridHeader extends React.Component {
eventComponent: elementType,
eventWrapperComponent: elementType.isRequired,
dateCellWrapperComponent: elementType,
timeGutterHeaderComponent: elementType,

onSelectSlot: PropTypes.func,
onSelectEvent: PropTypes.func,
Expand Down Expand Up @@ -148,6 +149,7 @@ class TimeGridHeader extends React.Component {
eventComponent,
dateCellWrapperComponent,
eventWrapperComponent,
timeGutterHeaderComponent: TimeGutterHeader,
} = this.props

let style = {}
Expand All @@ -161,7 +163,9 @@ class TimeGridHeader extends React.Component {
style={style}
className={cn('rbc-time-header', isOverflowing && 'rbc-overflowing')}
>
<div className="rbc-label rbc-time-header-gutter" style={{ width }} />
<div className="rbc-label rbc-time-header-gutter" style={{ width }}>
{TimeGutterHeader && <TimeGutterHeader />}
</div>

<div className="rbc-time-header-content">
<div className="rbc-row rbc-time-header-cell">
Expand Down
19 changes: 19 additions & 0 deletions stories/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,3 +561,22 @@ storiesOf('module.Calendar.week', module)
</div>
)
})
.add('custom time gutter header', () => {
const TimeGutter = () => <p>Custom gutter text</p>

return (
<div style={{ height: 600 }}>
<Calendar
popup
events={demoEvents}
onSelectEvent={action('event selected')}
defaultDate={new Date(2015, 3, 1)}
defaultView="week"
views={['week', 'day']}
components={{
timeGutterHeader: TimeGutter,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also update the propTypes in Calendar with appropriate documentation as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sure 😃

}}
/>
</div>
)
})