Skip to content

Commit

Permalink
feat: add timeGutterHeaderComponent (jquense#874)
Browse files Browse the repository at this point in the history
* Add timeGutterHeaderComponent
Closes jquense#853

* Make timeGutter component option act the same as other component options

* Add story for timeGutterHeader

* Add timeGutterHeader to Calendar propTypes
  • Loading branch information
danbovey authored and jquense committed Jul 3, 2018
1 parent db322f5 commit adc2078
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ class Calendar extends React.Component {
eventWrapper: elementType,
dayWrapper: elementType,
dateCellWrapper: elementType,
timeGutterHeader: elementType,

toolbar: elementType,

Expand Down
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 @@ -655,3 +655,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,
}}
/>
</div>
)
})

0 comments on commit adc2078

Please sign in to comment.