Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
a803455
add tests
Oct 14, 2018
048aff2
fix TimelineHeader tests + add error to getNextUnit helper
Oct 18, 2018
15a7a53
add error snapshot
Ilaiwi Oct 19, 2018
e4381a7
add tests senarios
Ilaiwi Oct 20, 2018
bcc026c
Merge pull request #470 from namespace-ee/develop
Ilaiwi Nov 16, 2018
bf5b9dc
update codesandbox
Ilaiwi Nov 16, 2018
9c56a25
add missing properties to `itemRendere`
Ilaiwi Dec 2, 2018
a5f76fa
stackItems attempt 2 (#424)
acemac Dec 7, 2018
40bff38
Stack2 refactor (#480)
Ilaiwi Dec 7, 2018
f213c0a
width-as-prop
Ilaiwi Dec 19, 2018
8993409
responsive to width changes
Ilaiwi Dec 19, 2018
387f834
responsive width prop
Ilaiwi Dec 19, 2018
6ed25c8
merge develop
Ilaiwi Dec 19, 2018
e606aae
width as prop
Ilaiwi Dec 19, 2018
3bc5eab
scroll to width if provided
Ilaiwi Dec 19, 2018
9ec8b1b
scroll
Ilaiwi Dec 19, 2018
afce566
scroll
Ilaiwi Dec 19, 2018
e9c614c
beta 2
Ilaiwi Dec 19, 2018
ad8248c
export utils
Ilaiwi Dec 22, 2018
2dc9518
export useful helpers
Ilaiwi Dec 22, 2018
073ec24
merge column change
Ilaiwi Dec 26, 2018
8a93aca
ok
Ilaiwi Dec 26, 2018
636aa5f
left
Ilaiwi Dec 26, 2018
a30eab4
7
Ilaiwi Dec 26, 2018
b9f28af
Merge branch 'custom-headers' of https://github.com/FoothillSolutions…
Ilaiwi Jan 2, 2019
53c1810
merge develop
Ilaiwi Jan 2, 2019
36170d1
Merge branch 'custom-headers' of https://github.com/FoothillSolutions…
Ilaiwi Jan 2, 2019
31b90a6
merge custom headers
Ilaiwi Jan 2, 2019
1502e4e
merge remote
Ilaiwi Jan 2, 2019
71518fb
add width to customheader
Ilaiwi Jan 2, 2019
8e1564d
custom header width
Ilaiwi Jan 2, 2019
a60f9f7
9
Ilaiwi Jan 2, 2019
d6d9cee
adding test cases for the timeline wrapper's child components api
sh-alawneh Jan 5, 2019
815f7d8
fix typos in the test cases of timeline wrapper's components api
sh-alawneh Jan 6, 2019
908b861
adding a new Test Case to The SidebarHeader test collection
sh-alawneh Jan 6, 2019
b25d9d4
9
Ilaiwi Jan 6, 2019
f7f385d
Merge branch 'custom-headers' of https://github.com/FoothillSolutions…
sh-alawneh Jan 6, 2019
b9ab291
implement tests and extract test cases to separate files
sh-alawneh Jan 6, 2019
496edb9
adding new test to the Timeline Component
sh-alawneh Jan 6, 2019
0e03bd3
implement timeline tests except the primary secondary test case
sh-alawneh Jan 6, 2019
db4af0f
implement the test for checking one secondary and one primary headers
sh-alawneh Jan 6, 2019
f09bbfb
update the test case one secondary and one primary
sh-alawneh Jan 7, 2019
572b1f4
implement the test cases in the sidebarHeader test file
sh-alawneh Jan 7, 2019
e0a560e
extend the test cases for the sidebarHeader component
sh-alawneh Jan 7, 2019
85483dc
remove unused imports
sh-alawneh Jan 7, 2019
47c80f7
do code refactoring
sh-alawneh Jan 7, 2019
c8e32f5
#484 Add check to if item can be moved (#485)
acemac Jan 14, 2019
9661032
fix componentDidUpdate #484
Ilaiwi Jan 14, 2019
be63235
Merge branch 'develop' of https://github.com/namespace-ee/react-calen…
Ilaiwi Jan 14, 2019
1ca8d0d
Fix sidebar re-render when groupHeights do not change (#479)
SDupZ Jan 14, 2019
56a8469
Merge branch 'master' of https://github.com/namespace-ee/react-calend…
Ilaiwi Jan 14, 2019
79ce954
add change log
Ilaiwi Jan 14, 2019
d9ea3bf
add example on stackItems
Ilaiwi Jan 14, 2019
74672c2
Merge pull request #492 from namespace-ee/develop
Ilaiwi Jan 14, 2019
08443aa
extend the test cases with some arrangments
sh-alawneh Jan 15, 2019
359449d
extend the test cases and make the descreption more descriptive
sh-alawneh Jan 16, 2019
a5c19a1
remove unused imports and variables, adding custom header test cases
sh-alawneh Jan 17, 2019
1647566
extend the custom header test cases
sh-alawneh Jan 22, 2019
b7b2cca
delete package lock
Ilaiwi Jan 22, 2019
40065f8
refactor how we calculate interval style
Ilaiwi Jan 22, 2019
c72f12d
Merge branch 'custom-headers-test' of https://github.com/FoothillSolu…
Ilaiwi Jan 22, 2019
c79f85b
fix selected controlled vs uncontrolled
Ilaiwi Jan 23, 2019
a9cacfe
select controlled vs uncontrolled
Ilaiwi Jan 23, 2019
d8f214a
beta 10
Ilaiwi Jan 23, 2019
28c94ee
check item ref before mounting interact
Ilaiwi Jan 24, 2019
c27cfd0
beta 11
Ilaiwi Jan 24, 2019
125522c
fix interacting with item that deosnt exist
Ilaiwi Jan 24, 2019
8965bb9
Merge branch '350' of https://github.com/namespace-ee/react-calendar-…
Ilaiwi Jan 24, 2019
8b37c9c
11
Ilaiwi Jan 24, 2019
0f3268f
pull
Ilaiwi Jan 27, 2019
a43f8e5
on update item
Ilaiwi Jan 27, 2019
0a8d21a
extends the test cases
sh-alawneh Jan 28, 2019
892fe56
Merge branch 'custom-headers-test' of https://github.com/FoothillSolu…
sh-alawneh Jan 28, 2019
b2d2349
docs: adding link to LICENSE.md to README.md
tobiasbueschel Feb 11, 2019
f98c738
docs: correct invalid JavaScript syntax in examples
tobiasbueschel Feb 13, 2019
cfe2794
stack
Ilaiwi Feb 19, 2019
6cf4444
merge beta
Ilaiwi Feb 19, 2019
f3a7b3f
Merge pull request #25 from FoothillSolutions/stack-items-beta
Ilaiwi Feb 19, 2019
103227d
Merge branch 'develop' of https://github.com/namespace-ee/react-calen…
Ilaiwi Feb 21, 2019
1b47281
Merge branch 'custom-headers' of https://github.com/FoothillSolutions…
Ilaiwi Feb 21, 2019
6b19330
docs: fix minor spelling mistakes + update links for react and react-…
tobiasbueschel Feb 26, 2019
d0c318f
Merge pull request #509 from tobiasbueschel/docs/readme-return
Ilaiwi Mar 6, 2019
139a0f8
Merge pull request #507 from tobiasbueschel/docs/readme
Ilaiwi Mar 6, 2019
4cb753b
merge
Ilaiwi Mar 6, 2019
730ec0d
pump
Ilaiwi Mar 8, 2019
ce23739
improve click handlers
Ilaiwi Mar 10, 2019
8550a3e
beta
Ilaiwi Mar 10, 2019
27fc1bd
Merge pull request #520 from tobiasbueschel/docs/spelling
Ilaiwi Mar 17, 2019
e88de29
fix height calculation of stacked items inconsistant
Ilaiwi Mar 18, 2019
1183f50
Merge branch '497' of https://github.com/namespace-ee/react-calendar-…
Ilaiwi Mar 18, 2019
e3e3d06
0.25.21
Ilaiwi Mar 18, 2019
289a677
change homepage and git URL
falfaddaghi Sep 19, 2019
fb8371d
Merge pull request #28 from FoothillSolutions/falfaddaghi-patch-1
falfaddaghi Sep 19, 2019
42ebee8
fix start of day in daylight saving
Abdallatif Mar 3, 2020
0c29f2a
Merge pull request #29 from FoothillSolutions/daylight-saving
falfaddaghi Mar 4, 2020
a6c3379
0.25.0-beta.22
Abdallatif Mar 4, 2020
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 .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A clear and concise description of what the bug is.

_Please provide one or both of the following:_

Code (If you have a branch somewhere that shows your issue) or link to codesandbox example. [Here's a base template for this library](https://codesandbox.io/s/lyjr9p0119):
Code (If you have a branch somewhere that shows your issue) or link to codesandbox example. [Here's a base template for this library](https://codesandbox.io/s/w6xvqzno4w):

OR

Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ bower_components
modules
build
gh-pages
lib
/lib
package-lock.json
# vscode stuff
.vscode

Expand Down
55 changes: 55 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,61 @@ and this project adheres (more or less) to [Semantic Versioning](http://semver.o

## Unreleased

## 0.23.0

- improve unit tests coverage #426 - @ilaiwi
- stack items by group #384 - @acemac
- fix bug where `canMove` prop gets ignored #484 - @acemac + @ilaiwi
- fix sidebar re-render when groupHeights do not change #478 - @SDupZ

### Stack per group

now you can stack choose to stack items in individual groups by providing the property `stackItems` in group object. The property in group overrides the timeline prop `stackItems`.

```
const groups = [{ id: 1, title: 'group 1', stackItems: false }, { id: 2, title: 'group 2', stackItems: true }]

const items = [
{
id: 1,
group: 1,
title: 'item 1',
start_time: moment(),
end_time: moment().add(1, 'hour')
},
{
id: 2,
group: 2,
title: 'item 2',
start_time: moment().add(-0.5, 'hour'),
end_time: moment().add(0.5, 'hour')
},
{
id: 3,
group: 1,
title: 'item 3',
start_time: moment().add(2, 'hour'),
end_time: moment().add(3, 'hour')
}
]

ReactDOM.render(
<div>
Rendered by react!
<Timeline
groups={groups}
items={items}
defaultTimeStart={moment().add(-12, 'hour')}
defaultTimeEnd={moment().add(12, 'hour')}
/>
</div>,
document.getElementById('root')
)
```


## 0.22.0

### Fixed

* Provided a new key `groupLabelKey` to allow splitting of the key used to render the Sidebar and the InfoLabel visible during drag operations. `groupTitleKey` continues to be used to render the Sidebar. #442 @thiagosatoshi
Expand Down
64 changes: 38 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# React Calendar Timeline

A modern and responsive react timeline component.
A modern and responsive React timeline component.

![calendar demo](https://raw.githubusercontent.com/namespace-ee/react-calendar-timeline/master/demo.gif)

Expand All @@ -16,7 +16,7 @@ yarn add react-calendar-timeline
npm install --save react-calendar-timeline
```

`react-calendar-timeline` has `react`, `react-dom`, [`moment`](http://momentjs.com/) and [`interactjs`](http://interactjs.io/docs/) as peer dependencies.
`react-calendar-timeline` has [react](https://reactjs.org/), [react-dom](https://reactjs.org/docs/react-dom.html), [`moment`](http://momentjs.com/) and [`interactjs`](http://interactjs.io/docs/) as peer dependencies.

# Usage

Expand Down Expand Up @@ -83,12 +83,12 @@ Expects either a vanilla JS array or an immutableJS array, consisting of objects
id: 1,
title: 'group 1',
rightTitle: 'title in the right sidebar',
stackItems?: true,
stackItems?: false or 'space' or 'line',
height?: 30
}
```

If you use right sidebar, you can pass optional `rightTitle` property here.
If you use the right sidebar, you can pass optional `rightTitle` property here.
If you want to overwrite the calculated height with a custom height, you can pass a `height` property as an int in pixels here. This can be very useful for categorized groups.

## items
Expand Down Expand Up @@ -118,15 +118,15 @@ Expects either a vanilla JS array or an immutableJS array, consisting of objects
}
```

The preferred (fastest) option is to give unix timestamps in milliseconds for `start_time` and `end_time`. Objects that convert to them (JavaScript Date or moment()) will also work, but will be a lot slower.
The preferred (fastest) option is to give Unix timestamps in milliseconds for `start_time` and `end_time`. Objects that convert to them (JavaScript `Date` or `moment()`) will also work, but will be a lot slower.

## defaultTimeStart and defaultTimeEnd

Unless overridden by `visibleTimeStart` and `visibleTimeEnd`, specify where the calendar begins and where it ends. This parameter expects a Date or moment object.

## visibleTimeStart and visibleTimeEnd

The exact viewport of the calendar. When these are specified, scrolling in the calendar must be orchestrated by the `onTimeChange` function. This parameter expects a unix timestamp in milliseconds.
The exact viewport of the calendar. When these are specified, scrolling in the calendar must be orchestrated by the `onTimeChange` function. This parameter expects a Unix timestamp in milliseconds.

**Note that you need to provide either `defaultTimeStart/End` or `visibleTimeStart/End` for the timeline to function**

Expand Down Expand Up @@ -179,8 +179,7 @@ The minimum width, in pixels, of a timeline entry when it's possible to resize.

## stickyOffset

At what height from the top of the screen should we start "sticking" the header (i.e. position: sticky)? This is useful if for example you already have
a sticky navbar and want to push the timeline header down further. Defaults `0`.
At what height from the top of the screen should we start "sticking" the header (i.e. position: sticky)? This is useful if for example you already have a sticky navbar and want to push the timeline header down further. Defaults `0`.

## stickyHeader

Expand Down Expand Up @@ -216,7 +215,7 @@ Largest time the calendar can zoom to in milliseconds. Default `5 * 365.24 * 864

## clickTolerance

How many pixels we can drag the background for it to be counted as a click on the background. Defualt: `3`
How many pixels we can drag the background for it to be counted as a click on the background. Default `3`

## canMove

Expand All @@ -238,6 +237,11 @@ Append a special `.rct-drag-right` handle to the elements and only resize if dra

Stack items under each other, so there is no visual overlap when times collide. Can be overridden in the `groups` array. Defaults to `false`.

can be assigned to
- false
- space (saves space in stacking)
- line (stack each item in a line)

## traditionalZoom

Zoom in when scrolling the mouse up/down. Defaults to `false`
Expand Down Expand Up @@ -332,6 +336,11 @@ function (action, item, time, resizeEdge) {
}
```

## onUpdateMove(itemId, time, newGroup, action,resizeEdge)

this function is called after moveResizeValidator on every drag update


## headerLabelFormats and subHeaderLabelFormats

The formats passed to moment to render times in the header and subheader. Defaults to these:
Expand Down Expand Up @@ -435,9 +444,9 @@ Called when the bounds in the calendar's canvas change. Use it for example to lo

## itemRenderer

Render prop function used to render a customized item. The function provides multiple paramerters that can be used to render each item.
Render prop function used to render a customized item. The function provides multiple parameters that can be used to render each item.

Paramters provided to the function has two types: context params which have the state of the item and timeline, and prop getters functions
Parameters provided to the function has two types: context params which have the state of the item and timeline, and prop getters functions

#### Render props params

Expand Down Expand Up @@ -468,10 +477,12 @@ Paramters provided to the function has two types: context params which have the
| `selected` | `boolean` | returns if the item is selected. |
| `dragging` | `boolean` | returns if the item is being dragged |
| `dragStart` | `object` | returns `x` and `y` of the start dragging point of the item. |
| `dragTime` | `number` | current drag time. |
| `dragGroupDelta` | `number` | returns number of groups the item moved. if negative, moving was to top. If positive, moving was to down |
| `resizing` | `boolean` | returns if the item is being resized. |
| `resizeEdge` | `left`, `right` | the side from which the component is being resized form |
| `resizeStart` | `number` | returns the x value from where the component start moving |
| `resizeTime` | `number` | current resize time |
| `width` | `boolean` | returns the width of the item (same as in dimensions) |

##### prop getters functions
Expand All @@ -488,7 +499,7 @@ Rather than applying props on the element yourself and to avoid your props being
* `getItemProps` returns the props you should apply to the root item element. The returned props are:

* key: item id
* ref: function to get item referance
* ref: function to get item reference
* className: classnames to be applied to the item
* onMouseDown: event handler
* onMouseUp: event handler
Expand All @@ -498,9 +509,9 @@ Rather than applying props on the element yourself and to avoid your props being
* onContextMenu: event handler
* style: inline object style

\*\* _the given styles will only override the styles that are not a requirement for postioning the item. Other styles like `color`, `radius` and others_
\*\* _the given styles will only override the styles that are not a requirement for positioning the item. Other styles like `color`, `radius` and others_

These properties can be override using the prop argument with proprties:
These properties can be override using the prop argument with properties:

* className: class names to be added
* onMouseDown: event handler will be called after the component's event handler
Expand Down Expand Up @@ -709,10 +720,10 @@ const twoSeconds = 2000

<TodayMarker>
{({ styles, date }) =>
// date is value of current date. Use this to render special styles for the marker
// or any other custom logic based on date:
// e.g. styles = {...styles, backgroundColor: isDateInAfternoon(date) ? 'red' : 'limegreen'}
return <div style={styles} />
// date is value of current date. Use this to render special styles for the marker
// or any other custom logic based on date:
// e.g. styles = {...styles, backgroundColor: isDateInAfternoon(date) ? 'red' : 'limegreen'}
<div style={styles} />
}
</TodayMarker>
```
Expand All @@ -735,9 +746,7 @@ const today = Date.now()

//custom renderer
<CustomMarker date={today}>
{({ styles, date }) =>
return <div style={styles} />
}
{({ styles, date }) => <div style={styles} />}
</CustomMarker>

// multiple CustomMarkers
Expand Down Expand Up @@ -767,10 +776,10 @@ Custom renderer for this marker. Ensure that you always pass `styles` to the roo
//custom renderer
<CursorMarker>
{({ styles, date }) =>
// date is value of current date. Use this to render special styles for the marker
// or any other custom logic based on date:
// e.g. styles = {...styles, backgroundColor: isDateInAfternoon(date) ? 'red' : 'limegreen'}
return <div style={styles} />
// date is value of current date. Use this to render special styles for the marker
// or any other custom logic based on date:
// e.g. styles = {...styles, backgroundColor: isDateInAfternoon(date) ? 'red' : 'limegreen'}
<div style={styles} />
}
</CursorMarker>
```
Expand Down Expand Up @@ -1318,7 +1327,7 @@ You need to include the `Timeline.css` file, either via static file reference or

## How can I have items with different colors?

Now you can use item renderer for rendering items with different colors [itemRenderer](https://github.com/namespace-ee/react-calendar-timeline#itemrenderer).
Now you can use item renderer for rendering items with different colors [itemRenderer](https://github.com/namespace-ee/react-calendar-timeline#itemrenderer).
Please refer to [examples](https://github.com/namespace-ee/react-calendar-timeline/tree/master/examples#custom-item-rendering) for a sandbox example

## How can I add a sidebar on the right?
Expand Down Expand Up @@ -1450,3 +1459,6 @@ npm version patch
```

-->

## License
[MIT licensed](/LICENSE.md).
25 changes: 12 additions & 13 deletions __fixtures__/itemsAndGroups.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,53 @@
import moment from 'moment'

export const items = [
{
id: '0',
group: '1',
start_time: moment('2018-10-26T10:46:40.000').valueOf(),
end_time: moment('2018-10-26T12:40:03.877').valueOf(),
start_time: 1540540000000,
end_time: 1540546803877,
canMove: false,
canResize: false
},
{
id: '5',
group: '1',
start_time: moment('2018-10-26T08:46:40.000').valueOf(),
end_time: moment('2018-10-26T14:40:03.877').valueOf(),
start_time: 1540532800000,
end_time: 1540554003877,
canMove: false,
canResize: false,
className: ''
},
{
id: '6',
group: '1',
start_time: moment('2018-10-26T13:46:40.000').valueOf(),
end_time: moment('2018-10-26T20:40:03.877').valueOf(),
start_time: 1540550800000,
end_time: 1540575603877,
canMove: false,
canResize: false,
className: ''
},
{
id: '1',
group: '1',
start_time: moment('2018-10-26T19:06:40.000').valueOf(),
end_time: moment('2018-10-26T23:14:35.919').valueOf(),
start_time: 1540570000000,
end_time: 1540584875919,
canMove: true,
canResize: 'both'
},
{
id: '2',
group: '1',
start_time: moment('2018-10-27T08:00:00.000').valueOf(),
end_time: moment('2018-10-27T13:39:57.548').valueOf(),
start_time: 1540620000000,
end_time: 1540640397548,
canMove: false,
canResize: false,
className: ''
},
{
id: '3',
group: '3',
start_time: moment('2018-10-27T18:00:00.000').valueOf(),
end_time: moment('2018-10-27T23:39:57.548').valueOf(),
start_time: 1540656000000,
end_time: 1540676397548,
canMove: false,
canResize: false,
className: ''
Expand Down
13 changes: 6 additions & 7 deletions __fixtures__/stateAndProps.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { defaultKeys } from 'lib/default-config'
import moment from 'moment'
import {items} from './itemsAndGroups'
export const props = {
keys: defaultKeys,
lineHeight: 30,
stackItems: true,
stackItems: 'space',
itemHeightRatio: 0.75
}

Expand All @@ -13,8 +12,8 @@ export const propsNoStack = {
stackItems: false,
}

export const visibleTimeStart = moment('2018-10-26T00:00:00.000')
export const visibleTimeEnd = moment('2018-10-27T00:00:00.000')
export const visibleTimeStart = 1540501200000
export const visibleTimeEnd = 1540587600000

export const state = {
draggingItem: undefined,
Expand All @@ -23,9 +22,9 @@ export const state = {
resizingEdge: null,
resizeTime: null,
newGroupOrder: null,
canvasTimeStart: moment('2018-10-25T00:00:00.000').valueOf(),
visibleTimeEnd: visibleTimeEnd.valueOf(),
visibleTimeStart: visibleTimeStart.valueOf(),
canvasTimeStart: 1540414800000,
visibleTimeEnd: visibleTimeEnd,
visibleTimeStart: visibleTimeStart,
canvasTimeEnd: 1540674000000,
width: 1000,
}
Expand Down
Loading