Skip to content

0.26.0 alpha #27

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

Open
wants to merge 32 commits into
base: 0.25.0-beta
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
50b6c99
fix(TimelineMarkers): Unsubscribing hidden markers correctly
Feb 27, 2019
48546c6
Merge pull request #525 from gaston-niglia/fix/unsubscribing-markers
Ilaiwi Mar 17, 2019
19f3db6
Merge branch 'develop' of https://github.com/namespace-ee/react-calen…
Ilaiwi Mar 18, 2019
a6486e8
Merge branch 'custom-headers' of https://github.com/FoothillSolutions…
Ilaiwi Mar 18, 2019
f8657e0
fix broken tests
Ilaiwi Mar 18, 2019
7703421
refactor to use context and not timeline
Ilaiwi Mar 19, 2019
aa566a0
check tests and add TODOs
Ilaiwi Mar 19, 2019
2069dca
finalize SidebarHeader and TimelineHeader tests
Ilaiwi Mar 20, 2019
44d367f
Custom headers tests
Ilaiwi Mar 24, 2019
db46dd4
DateHeader
Ilaiwi Mar 25, 2019
74ffee4
fix broken tests
Ilaiwi Mar 26, 2019
46e72f9
delete snapshots + fix travis moment errors
Ilaiwi Mar 26, 2019
11662cd
pull code changes from tests
Ilaiwi Mar 26, 2019
1199d66
Merge branch 'custom-headers' of https://github.com/FoothillSolutions…
Ilaiwi Mar 26, 2019
8eb05f2
headerRef + sticky header
Ilaiwi Mar 26, 2019
8fb2a7a
unify left width calculation
Ilaiwi Mar 26, 2019
78a8daa
add documentation for left and right sidebar header
Ilaiwi Mar 26, 2019
8a86071
delete headerLabelHeight + remove extra header classes
Ilaiwi Mar 26, 2019
9abdd45
Merge branch 'custom-headers' of https://github.com/FoothillSolutions…
Ilaiwi Mar 26, 2019
e98aacf
pass primary as unit and remove secondary
Ilaiwi Mar 27, 2019
d727683
primary header
Ilaiwi Mar 27, 2019
4c02b20
Merge branch 'custom-headers' of https://github.com/FoothillSolutions…
Ilaiwi Mar 27, 2019
96e3e47
sidebarheader to accept component as a child
Ilaiwi Mar 27, 2019
f018881
convert DateHeader and CustomHeader to use headerData
Ilaiwi Mar 27, 2019
34f2c28
remove labelFormat object option
Ilaiwi Mar 28, 2019
766220e
remove inline styles and replace them with classnames
Ilaiwi Mar 28, 2019
d5cba6e
update readme
Ilaiwi Mar 28, 2019
9ab5d4e
add height prop
Ilaiwi Apr 1, 2019
6aced20
merge headers
Ilaiwi Apr 3, 2019
ad92d55
fix failing height test
Ilaiwi Apr 3, 2019
b267cb7
Merge branch 'custom-headers-test' of https://github.com/FoothillSolu…
Ilaiwi Apr 3, 2019
527d339
wdith
Ilaiwi Apr 3, 2019
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
Prev Previous commit
Next Next commit
unify left width calculation
  • Loading branch information
Ilaiwi committed Mar 26, 2019
commit 8fb2a7a244330ec84d673124a9e4f226dba9c01c
56 changes: 38 additions & 18 deletions src/lib/columns/Columns.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@ import PropTypes from 'prop-types'
import React, { Component } from 'react'

import { iterateTimes } from '../utility/calendar'
import { TimelineStateConsumer } from '../timeline/TimelineStateContext'

export default class Columns extends Component {
const passThroughPropTypes = {
canvasTimeStart: PropTypes.number.isRequired,
canvasTimeEnd: PropTypes.number.isRequired,
canvasWidth: PropTypes.number.isRequired,
lineCount: PropTypes.number.isRequired,
minUnit: PropTypes.string.isRequired,
timeSteps: PropTypes.object.isRequired,
height: PropTypes.number.isRequired,
verticalLineClassNamesForTime: PropTypes.func
}

class Columns extends Component {
static propTypes = {
canvasTimeStart: PropTypes.number.isRequired,
canvasTimeEnd: PropTypes.number.isRequired,
canvasWidth: PropTypes.number.isRequired,
lineCount: PropTypes.number.isRequired,
minUnit: PropTypes.string.isRequired,
timeSteps: PropTypes.object.isRequired,
height: PropTypes.number.isRequired,
verticalLineClassNamesForTime: PropTypes.func
...passThroughPropTypes,
getLeftOffsetFromDate: PropTypes.func.isRequired
}

shouldComponentUpdate(nextProps) {
Expand All @@ -37,7 +43,8 @@ export default class Columns extends Component {
minUnit,
timeSteps,
height,
verticalLineClassNamesForTime
verticalLineClassNamesForTime,
getLeftOffsetFromDate
} = this.props
const ratio = canvasWidth / (canvasTimeEnd - canvasTimeStart)

Expand All @@ -49,13 +56,8 @@ export default class Columns extends Component {
minUnit,
timeSteps,
(time, nextTime) => {
const left = Math.round((time.valueOf() - canvasTimeStart) * ratio, -2)
const minUnitValue = time.get(minUnit === 'day' ? 'date' : minUnit)
const firstOfType = minUnitValue === (minUnit === 'day' ? 1 : 0)
const lineWidth = firstOfType ? 2 : 1
const labelWidth =
Math.ceil((nextTime.valueOf() - time.valueOf()) * ratio) - lineWidth
const leftPush = firstOfType ? -1 : 0

let classNamesForTime = []
if (verticalLineClassNamesForTime) {
Expand All @@ -74,15 +76,17 @@ export default class Columns extends Component {
: '') +
classNamesForTime.join(' ')

const left = getLeftOffsetFromDate(time.valueOf())
const right = getLeftOffsetFromDate(nextTime.valueOf())
lines.push(
<div
key={`line-${time.valueOf()}`}
className={classNames}
style={{
pointerEvents: 'none',
top: '0px',
left: `${left + leftPush}px`,
width: `${labelWidth}px`,
left: `${left}px`,
width: `${right - left}px`,
height: `${height}px`
}}
/>
Expand All @@ -92,4 +96,20 @@ export default class Columns extends Component {

return <div className="rct-vertical-lines">{lines}</div>
}
}
}

const ColumnsWrapper = ({ ...props }) => {
return (
<TimelineStateConsumer>
{({ getLeftOffsetFromDate }) => (
<Columns getLeftOffsetFromDate={getLeftOffsetFromDate} {...props} />
)}
</TimelineStateConsumer>
)
}

ColumnsWrapper.defaultProps = {
...passThroughPropTypes
}

export default ColumnsWrapper