11import React from 'react'
2+ import classNames from 'classnames'
23import { TimelineHeadersConsumer } from './HeadersContext'
34import PropTypes from 'prop-types'
45import SidebarHeader from './SidebarHeader'
5- import { RIGHT_VARIANT , LEFT_VARIANT } from './constants'
6+ import { RIGHT_VARIANT } from './constants'
67class TimelineHeaders extends React . Component {
78 static propTypes = {
89 registerScroll : PropTypes . func . isRequired ,
910 leftSidebarWidth : PropTypes . number . isRequired ,
1011 rightSidebarWidth : PropTypes . number . isRequired ,
1112 style : PropTypes . object ,
13+ children : PropTypes . node ,
1214 className : PropTypes . string ,
1315 calendarHeaderStyle : PropTypes . object ,
1416 calendarHeaderClassName : PropTypes . string ,
15- headerRef : PropTypes . func ,
17+ headerRef : PropTypes . func
1618 }
1719
1820 constructor ( props ) {
@@ -40,8 +42,8 @@ class TimelineHeaders extends React.Component {
4042 }
4143 }
4244
43- handleRootRef = ( element ) => {
44- if ( this . props . headerRef ) {
45+ handleRootRef = element => {
46+ if ( this . props . headerRef ) {
4547 this . props . headerRef ( element )
4648 }
4749 }
@@ -64,24 +66,27 @@ class TimelineHeaders extends React.Component {
6466 calendarHeaders . push ( child )
6567 }
6668 } )
67- if ( ! leftSidebarHeader ) {
68- leftSidebarHeader = < SidebarHeader />
69+ if ( ! leftSidebarHeader ) {
70+ leftSidebarHeader = < SidebarHeader />
6971 }
70- if ( ! rightSidebarHeader && this . props . rightSidebarWidth ) {
71- rightSidebarHeader = < SidebarHeader variant = "right" />
72+ if ( ! rightSidebarHeader && this . props . rightSidebarWidth ) {
73+ rightSidebarHeader = < SidebarHeader variant = "right" />
7274 }
7375 return (
7476 < div
7577 ref = { this . handleRootRef }
7678 data-testid = "headerRootDiv"
7779 style = { this . getRootStyle ( ) }
78- className = { ` rct-header-root ${ this . props . className } ` }
80+ className = { classNames ( ' rct-header-root' , this . props . className ) }
7981 >
8082 { leftSidebarHeader }
8183 < div
8284 ref = { this . props . registerScroll }
8385 style = { this . getCalendarHeaderStyle ( ) }
84- className = { `rct-calendar-header ${ this . props . calendarHeaderClassName } ` }
86+ className = { classNames (
87+ 'rct-calendar-header' ,
88+ this . props . calendarHeaderClassName
89+ ) }
8590 data-testid = "headerContainer"
8691 >
8792 { calendarHeaders }
@@ -106,23 +111,24 @@ const TimelineHeadersWrapper = ({
106111 leftSidebarWidth = { leftSidebarWidth }
107112 rightSidebarWidth = { rightSidebarWidth }
108113 registerScroll = { registerScroll }
109- children = { children }
110114 style = { style }
111115 className = { className }
112116 calendarHeaderStyle = { calendarHeaderStyle }
113117 calendarHeaderClassName = { calendarHeaderClassName }
114- />
118+ >
119+ { children }
120+ </ TimelineHeaders >
115121 )
116122 } }
117123 </ TimelineHeadersConsumer >
118124)
119125
120126TimelineHeadersWrapper . propTypes = {
121127 style : PropTypes . object ,
128+ children : PropTypes . node ,
122129 className : PropTypes . string ,
123130 calendarHeaderStyle : PropTypes . object ,
124- calendarHeaderClassName : PropTypes . string ,
125- headerRef : PropTypes . func ,
131+ calendarHeaderClassName : PropTypes . string
126132}
127133
128134export default TimelineHeadersWrapper
0 commit comments