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

Fix Various Issues and Add Enhancements to Timeline Component #944

Merged
merged 12 commits into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from 11 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
2 changes: 1 addition & 1 deletion src/lib/Timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ export default class ReactCalendarTimeline<
(prevState.width * (prevState.visibleTimeStart - prevState.canvasTimeStart)) / oldZoom,
)

if (componentScrollLeft !== scrollLeft) {
if (componentScrollLeft !== scrollLeft || this.scrollComponent!.scrollLeft !== scrollLeft) {
this.scrollComponent!.scrollLeft = scrollLeft
this.scrollHeaderRef!.scrollLeft = scrollLeft
}
Expand Down
3 changes: 1 addition & 2 deletions src/lib/headers/CustomHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ class CustomHeader<Data> extends React.Component<CustomHeaderProps<Data>, State>

render() {
const props = this.getStateAndHelpers()
const Renderer = this.props.children
return <Renderer {...props} />
return this.props.children(props)
}
}

Expand Down
19 changes: 9 additions & 10 deletions src/lib/headers/Interval.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,16 @@ class Interval<Data> extends React.PureComponent<IntervalProps<Data>> {
const { intervalText, interval, intervalRenderer, headerData } = this.props
const Renderer = intervalRenderer
if (Renderer) {
return (
<Renderer
getIntervalProps={this.getIntervalProps}
intervalContext={{
interval,
intervalText,
}}
data={headerData}
/>
)
return Renderer({
getIntervalProps: this.getIntervalProps,
intervalContext: {
interval,
intervalText,
},
data: headerData,
})
}

const { key, ...rest } = this.getIntervalProps()
return (
<div
Expand Down
9 changes: 4 additions & 5 deletions src/lib/headers/SidebarHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ComponentType, CSSProperties, HTMLProps, PureComponent } from 'react'
import { CSSProperties, HTMLProps, PureComponent, ReactNode } from 'react'
import { useTimelineHeadersContext } from './HeadersContext'
import { LEFT_VARIANT, RIGHT_VARIANT } from './constants'

type SidebarHeaderProps = {
children: ComponentType<{ getRootProps: GetRootProps }>
children: (props: { getRootProps: GetRootProps }) => ReactNode
rightSidebarWidth?: number
leftSidebarWidth: number
variant: typeof LEFT_VARIANT | typeof RIGHT_VARIANT
Expand Down Expand Up @@ -31,15 +31,14 @@ class SidebarHeader extends PureComponent<SidebarHeaderProps> {

render() {
const props = this.getStateAndHelpers()
const Renderer = this.props.children
return <Renderer {...props} />
return this.props.children(props)
}
}

type GetRootProps = () => HTMLProps<HTMLDivElement>

export type SidebarWrapperProps = {
children?: ComponentType<{ getRootProps: GetRootProps }>
children?: (props: { getRootProps: GetRootProps }) => ReactNode
variant?: typeof LEFT_VARIANT | typeof RIGHT_VARIANT
headerData?: any
}
Expand Down
5 changes: 4 additions & 1 deletion src/lib/utility/calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ export function iterateTimes(
}

while (time.valueOf() < end) {
const nextTime = dayjs(time).add(timeSteps[unit] || 1, unit as dayjs.ManipulateType)
const nextTime = dayjs(time)
.add(timeSteps[unit] || 1, unit as dayjs.ManipulateType)
.startOf(unit)

callback(time, nextTime)
time = nextTime
}
Expand Down