Skip to content

Commit 8e4063d

Browse files
authored
Merge branch 'master' into feature/unit-in-onZoom-and-onTimeChange-callbacks
2 parents c81ef85 + db8fdb9 commit 8e4063d

File tree

9 files changed

+42
-35
lines changed

9 files changed

+42
-35
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ and this project adheres (more or less) to [Semantic Versioning](http://semver.o
88
## Unreleased
99

1010
* Add unit argument to onZoom and onTimeChange callbacks
11+
* Add `className` prop to Timeline component to override `react-calendar-timeline` class #682
12+
* Fix injecting custom vertical line's class names for time periods longer than day
1113

1214
## 0.26.7
1315

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ An array specifying keys in the `items` and `groups` objects. Defaults to
162162
}
163163
```
164164

165+
## className
166+
167+
Additional class names as a string for the root Timeline element.
168+
165169
## sidebarWidth
166170

167171
Width of the sidebar in pixels. If set to `0`, the sidebar is not rendered. Defaults to `150`.
@@ -300,11 +304,11 @@ Called when the item is clicked by the right button of the mouse. `time` is the
300304

301305
Called when an empty spot on the canvas was clicked. Get the group ID and the time as arguments. For example open a "new item" window after this.
302306

303-
## onCanvasDoubleClick(group, time, e)
307+
## onCanvasDoubleClick(groupId, time, e)
304308

305-
Called when an empty spot on the canvas was double clicked. Get the group and the time as arguments.
309+
Called when an empty spot on the canvas was double clicked. Get the group ID and the time as arguments.
306310

307-
## onCanvasContextMenu(group, time, e)
311+
## onCanvasContextMenu(groupId, time, e)
308312

309313
Called when the canvas is clicked by the right button of the mouse. Note: If this property is set the default context menu doesn't appear
310314

@@ -431,7 +435,8 @@ Rather than applying props on the element yourself and to avoid your props being
431435
* onTouchEnd: event handler
432436
* onDoubleClick: event handler
433437
* onContextMenu: event handler
434-
* style: inline object style
438+
* style: inline object
439+
435440

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

@@ -1258,7 +1263,7 @@ $ yarn start
12581263

12591264
Check http://0.0.0.0:8888/ in your browser and have fun!
12601265

1261-
Please run `npm run lint` before you send a pull request. `npm run jest` runs the tests.
1266+
Please run `npm run lint` before you send a pull request. `npm run test` runs the jest tests.
12621267

12631268
<!--
12641269

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Controlled visible port of the calendar using `visibleTimeStart` and `visibleTim
7070

7171
Using controlled scroll and react-spring to trigger scrolling and create an animation.
7272

73-
[Example Codesandbox](https://codesandbox.io/s/confident-waterfall-3kq2503y8p)
73+
[Example Codesandbox](https://codesandbox.io/s/timeline-demo-programmatic-scroll-3kq2503y8p)
7474

7575
## Sticky header
7676

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-calendar-timeline",
3-
"version": "0.26.7",
3+
"version": "0.27.0",
44
"description": "react calendar timeline",
55
"main": "lib/index.js",
66
"scripts": {
@@ -93,7 +93,7 @@
9393
},
9494
"dependencies": {
9595
"classnames": "^2.2.6",
96-
"create-react-context": "^0.2.2",
96+
"create-react-context": "^0.3.0",
9797
"element-resize-detector": "^1.1.12",
9898
"lodash.isequal": "^4.5.0",
9999
"memoize-one": "^5.1.1"

src/lib/Timeline.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export default class ReactCalendarTimeline extends Component {
8282
itemRenderer: PropTypes.func,
8383
groupRenderer: PropTypes.func,
8484

85+
className: PropTypes.string,
8586
style: PropTypes.object,
8687

8788
keys: PropTypes.shape({
@@ -208,6 +209,7 @@ export default class ReactCalendarTimeline extends Component {
208209
itemTouchSendsClick: false,
209210

210211
style: {},
212+
className: '',
211213
keys: defaultKeys,
212214
timeSteps: defaultTimeSteps,
213215
headerRef: () => {},
@@ -580,7 +582,7 @@ export default class ReactCalendarTimeline extends Component {
580582

581583
let zoom = visibleTimeEnd - visibleTimeStart
582584
// can't zoom in more than to show one hour
583-
if (zoom < 360000) {
585+
if (zoom < this.props.minZoom) {
584586
return
585587
}
586588

@@ -837,7 +839,7 @@ export default class ReactCalendarTimeline extends Component {
837839
itemDrag={this.dragItem}
838840
itemDrop={this.dropItem}
839841
onItemDoubleClick={this.doubleClickItem}
840-
onItemContextMenu={this.contextMenuClickItem}
842+
onItemContextMenu={this.props.onItemContextMenu ? this.contextMenuClickItem : undefined}
841843
itemResizing={this.resizingItem}
842844
itemResized={this.resizedItem}
843845
itemRenderer={this.props.itemRenderer}
@@ -1058,7 +1060,7 @@ export default class ReactCalendarTimeline extends Component {
10581060
<div
10591061
style={this.props.style}
10601062
ref={el => (this.container = el)}
1061-
className="react-calendar-timeline"
1063+
className={`react-calendar-timeline ${this.props.className}`}
10621064
>
10631065
{this.renderHeaders()}
10641066
<div style={outerComponentStyle} className="rct-outer">

src/lib/columns/Columns.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class Columns extends Component {
7373
(firstOfType ? ' rct-vl-first' : '') +
7474
(minUnit === 'day' || minUnit === 'hour' || minUnit === 'minute'
7575
? ` rct-day-${time.day()} `
76-
: '') +
76+
: ' ') +
7777
classNamesForTime.join(' ')
7878

7979
const left = getLeftOffsetFromDate(time.valueOf())
@@ -112,4 +112,4 @@ ColumnsWrapper.defaultProps = {
112112
...passThroughPropTypes
113113
}
114114

115-
export default ColumnsWrapper
115+
export default ColumnsWrapper

src/lib/default-config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ export const defaultHeaderFormats = {
5656
mediumLong: 'HH:mm',
5757
medium: 'HH:mm',
5858
short: 'mm',
59-
}
59+
},
60+
second: {
61+
"long": 'mm:ss',
62+
mediumLong: 'mm:ss',
63+
medium: 'mm:ss',
64+
"short": 'ss'
65+
}
6066
}
6167

6268
//TODO: delete this

src/lib/utility/dom-helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function getSumScroll(node) {
3737
}
3838

3939
export function getSumOffset(node) {
40-
if (node === document.body) {
40+
if (node === document.body || !node.offsetParent) {
4141
return {offsetLeft: 0, offsetTop: 0}
4242
} else {
4343
const parent = getSumOffset(node.offsetParent)

yarn.lock

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,12 +2224,13 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4:
22242224
safe-buffer "^5.0.1"
22252225
sha.js "^2.4.8"
22262226

2227-
create-react-context@^0.2.2:
2228-
version "0.2.2"
2229-
resolved "https://registry.yarnpkg.com/create-react-context/-/create-react-context-0.2.2.tgz#9836542f9aaa22868cd7d4a6f82667df38019dca"
2227+
create-react-context@^0.3.0:
2228+
version "0.3.0"
2229+
resolved "https://registry.yarnpkg.com/create-react-context/-/create-react-context-0.3.0.tgz#546dede9dc422def0d3fc2fe03afe0bc0f4f7d8c"
2230+
integrity sha512-dNldIoSuNSvlTJ7slIKC/ZFGKexBMBrrcc+TTe1NdmROnaASuLPvqpwj9v4XS4uXZ8+YPu0sNmShX2rXI5LNsw==
22302231
dependencies:
2231-
fbjs "^0.8.0"
22322232
gud "^1.0.0"
2233+
warning "^4.0.3"
22332234

22342235
cross-env@^5.1.4:
22352236
version "5.1.4"
@@ -3300,18 +3301,6 @@ fb-watchman@^2.0.0:
33003301
dependencies:
33013302
bser "^2.0.0"
33023303

3303-
fbjs@^0.8.0:
3304-
version "0.8.17"
3305-
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.17.tgz#c4d598ead6949112653d6588b01a5cdcd9f90fdd"
3306-
dependencies:
3307-
core-js "^1.0.0"
3308-
isomorphic-fetch "^2.1.1"
3309-
loose-envify "^1.0.0"
3310-
object-assign "^4.1.0"
3311-
promise "^7.1.1"
3312-
setimmediate "^1.0.5"
3313-
ua-parser-js "^0.7.18"
3314-
33153304
fbjs@^0.8.16:
33163305
version "0.8.16"
33173306
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.16.tgz#5e67432f550dc41b572bf55847b8aca64e5337db"
@@ -8043,10 +8032,6 @@ typescript@^2.5.1:
80438032
version "2.6.2"
80448033
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.6.2.tgz#3c5b6fd7f6de0914269027f03c0946758f7673a4"
80458034

8046-
ua-parser-js@^0.7.18:
8047-
version "0.7.18"
8048-
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.18.tgz#a7bfd92f56edfb117083b69e31d2aa8882d4b1ed"
8049-
80508035
ua-parser-js@^0.7.9:
80518036
version "0.7.17"
80528037
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.17.tgz#e9ec5f9498b9ec910e7ae3ac626a805c4d09ecac"
@@ -8288,6 +8273,13 @@ warning@^3.0.0:
82888273
dependencies:
82898274
loose-envify "^1.0.0"
82908275

8276+
warning@^4.0.3:
8277+
version "4.0.3"
8278+
resolved "https://registry.yarnpkg.com/warning/-/warning-4.0.3.tgz#16e9e077eb8a86d6af7d64aa1e05fd85b4678ca3"
8279+
integrity sha512-rpJyN222KWIvHJ/F53XSZv0Zl/accqHR8et1kpaMTD/fLCRxtV8iX8czMzY7sVZupTI3zcUTg8eycS2kNF9l6w==
8280+
dependencies:
8281+
loose-envify "^1.0.0"
8282+
82918283
watchpack@^1.5.0:
82928284
version "1.6.0"
82938285
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-1.6.0.tgz#4bc12c2ebe8aa277a71f1d3f14d685c7b446cd00"

0 commit comments

Comments
 (0)