Skip to content

Commit

Permalink
Add showAllEvents Calendar Prop
Browse files Browse the repository at this point in the history
This prop will allow the rows in the `month` view to display
all events in a scrollable container, rather than use the
`show more` capability.
  • Loading branch information
jhoangatl committed Nov 12, 2020
1 parent 41104fa commit f54447d
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 15 deletions.
8 changes: 8 additions & 0 deletions src/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,14 @@ class Calendar extends React.Component {
*/
onShowMore: PropTypes.func,

/**
* Displays all events on the month view instead of
* having some hidden behind +{count} more. This will
* cause the rows in the month view to be scrollable if
* the number of events exceed the height of the row.
*/
showAllEvents: PropTypes.bool,

/**
* The selected event, if any.
*/
Expand Down
46 changes: 32 additions & 14 deletions src/DateContentRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,15 @@ class DateContentRow extends React.Component {
}

renderDummy = () => {
let { className, range, renderHeader } = this.props
let { className, range, renderHeader, showAllEvents } = this.props
return (
<div className={className}>
<div className="rbc-row-content">
<div
className={clsx(
'rbc-row-content',
showAllEvents && 'rbc-row-content-scrollable'
)}
>
{renderHeader && (
<div className="rbc-row" ref={this.createHeadingRef}>
{range.map(this.renderHeadingCell)}
Expand Down Expand Up @@ -118,6 +123,7 @@ class DateContentRow extends React.Component {
longPressThreshold,
isAllDay,
resizable,
showAllEvents,
} = this.props

if (renderForMeasure) return this.renderDummy()
Expand Down Expand Up @@ -159,24 +165,35 @@ class DateContentRow extends React.Component {
resourceId={resourceId}
/>

<div className="rbc-row-content">
<div
className={clsx(
'rbc-row-content',
showAllEvents && 'rbc-row-content-scrollable'
)}
>
{renderHeader && (
<div className="rbc-row " ref={this.createHeadingRef}>
{range.map(this.renderHeadingCell)}
</div>
)}
<WeekWrapper isAllDay={isAllDay} {...eventRowProps}>
{levels.map((segs, idx) => (
<EventRow key={idx} segments={segs} {...eventRowProps} />
))}
{!!extra.length && (
<EventEndingRow
segments={extra}
onShowMore={this.handleShowMore}
{...eventRowProps}
/>
<div
className={clsx(
showAllEvents && 'rbc-row-content-scroll-container'
)}
</WeekWrapper>
>
<WeekWrapper isAllDay={isAllDay} {...eventRowProps}>
{levels.map((segs, idx) => (
<EventRow key={idx} segments={segs} {...eventRowProps} />
))}
{!!extra.length && (
<EventEndingRow
segments={extra}
onShowMore={this.handleShowMore}
{...eventRowProps}
/>
)}
</WeekWrapper>
</div>
</div>
</div>
)
Expand All @@ -200,6 +217,7 @@ DateContentRow.propTypes = {
longPressThreshold: PropTypes.number,

onShowMore: PropTypes.func,
showAllEvents: PropTypes.bool,
onSelectSlot: PropTypes.func,
onSelect: PropTypes.func,
onSelectEnd: PropTypes.func,
Expand Down
5 changes: 4 additions & 1 deletion src/Month.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class MonthView extends React.Component {
longPressThreshold,
accessors,
getters,
showAllEvents,
} = this.props

const { needLimitMeasure, rowLimit } = this.state
Expand All @@ -120,7 +121,7 @@ class MonthView extends React.Component {
date={date}
range={week}
events={events}
maxRows={rowLimit}
maxRows={showAllEvents ? Infinity : rowLimit}
selected={selected}
selectable={selectable}
components={components}
Expand All @@ -137,6 +138,7 @@ class MonthView extends React.Component {
longPressThreshold={longPressThreshold}
rtl={this.props.rtl}
resizable={this.props.resizable}
showAllEvents={showAllEvents}
/>
)
}
Expand Down Expand Up @@ -342,6 +344,7 @@ MonthView.propTypes = {
onDoubleClickEvent: PropTypes.func,
onKeyPressEvent: PropTypes.func,
onShowMore: PropTypes.func,
showAllEvents: PropTypes.bool,
onDrillDown: PropTypes.func,
getDrilldownView: PropTypes.func.isRequired,

Expand Down
10 changes: 10 additions & 0 deletions src/less/styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@
z-index: 4;
}

.rbc-row-content-scrollable {
display: flex;
flex-direction: column;
height: 100%;

.rbc-row-content-scroll-container {
overflow-y: scroll;
}
}

.rbc-today {
background-color: @today-highlight-bg;
}
Expand Down
10 changes: 10 additions & 0 deletions src/sass/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@
z-index: 4;
}

.rbc-row-content-scrollable {
display: flex;
flex-direction: column;
height: 100%;

.rbc-row-content-scroll-container {
overflow-y: scroll;
}
}

.rbc-today {
background-color: $today-highlight-bg;
}
Expand Down

0 comments on commit f54447d

Please sign in to comment.