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

feat: adds currentTimeIndicator component to Calendar #1

Merged
merged 1 commit into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions src/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ class Calendar extends React.Component {
* timeSlotWrapper: MyTimeSlotWrapper,
* timeGutterHeader: MyTimeGutterWrapper,
* resourceHeader: MyResourceHeader,
* currentTimeIndicator: MyCurrentTimeIndicator,
* toolbar: MyToolbar,
* agenda: {
* event: MyAgendaEvent, // with the agenda view use a different component to render events
Expand Down Expand Up @@ -764,6 +765,8 @@ class Calendar extends React.Component {
timeGutterHeader: PropTypes.elementType,
resourceHeader: PropTypes.elementType,

currentTimeIndicator: PropTypes.elementType,

toolbar: PropTypes.elementType,

agenda: PropTypes.shape({
Expand Down
12 changes: 12 additions & 0 deletions src/CurrentTimeIndicator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import PropTypes from 'prop-types'
import React from 'react'

const CurrentTimeIndicator = ({ position }) => (
<div className="rbc-current-time-indicator" style={{ top: `${position}%` }} />
)

CurrentTimeIndicator.propTypes = {
position: PropTypes.number,
}

export default CurrentTimeIndicator
9 changes: 6 additions & 3 deletions src/DayColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import TimeSlotGroup from './TimeSlotGroup'
import TimeGridEvent from './TimeGridEvent'
import { DayLayoutAlgorithmPropType } from './utils/propTypes'

import CurrentTimeIndicator from './CurrentTimeIndicator'
import DayColumnWrapper from './DayColumnWrapper'

class DayColumn extends React.Component {
Expand Down Expand Up @@ -124,6 +125,9 @@ class DayColumn extends React.Component {

const { className, style } = dayProp(max)

const CurrentTimeIndicatorComponent =
components.currentTimeIndicator || CurrentTimeIndicator

const DayColumnWrapperComponent =
components.dayColumnWrapper || DayColumnWrapper

Expand Down Expand Up @@ -173,9 +177,8 @@ class DayColumn extends React.Component {
</div>
)}
{isNow && this.intervalTriggered && (
<div
className="rbc-current-time-indicator"
style={{ top: `${this.state.timeIndicatorPosition}%` }}
<CurrentTimeIndicatorComponent
position={this.state.timeIndicatorPosition}
/>
)}
</DayColumnWrapperComponent>
Expand Down