# ⚠️⚠️⚠️⚠️ HELP WANTED
please email me [ahmad.ilaiwi@gmail.com](mailto:ahmad.ilaiwi@gmail.com) and we will setup some time to speak and see if you can help maintain this library.
# React Calendar Timeline
A modern and responsive React timeline component.
![calendar demo](https://raw.githubusercontent.com/namespace-ee/react-calendar-timeline/master/demo.gif)
Checkout the [examples here](https://github.com/namespace-ee/react-calendar-timeline/tree/master/examples)!
# Contents
- [Getting Started](#getting-started)
- [Usage](#usage)
- [API](#api)
- [Timeline Markers](#timeline-markers)
- [Timeline Headers](#timeline-headers)
- [FAQ](#faq)
- [Contribute](#contribute)
# Getting started
```bash
# via yarn
yarn add react-calendar-timeline
# via npm
npm install --save react-calendar-timeline
```
`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
At the very minimum:
```jsx
import Timeline from 'react-calendar-timeline'
// make sure you include the timeline stylesheet or the timeline will not be styled
import 'react-calendar-timeline/lib/Timeline.css'
import moment from 'moment'
const groups = [{ id: 1, title: 'group 1' }, { id: 2, title: 'group 2' }]
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')
)
```
# API
_NB!_ All props need to be immutable. For example, this means if you wish to change the title of one of your items, please pass in a whole new items array instead of changing the title in the old array. [Here's more info.](http://reactkungfu.com/2015/08/pros-and-cons-of-using-immutability-with-react-js/)
The component can take many props:
## groups
Expects either a vanilla JS array or an immutableJS array, consisting of objects with the following attributes:
```js
{
id: 1,
title: 'group 1',
rightTitle: 'title in the right sidebar',
stackItems?: true,
height?: 30
}
```
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
Expects either a vanilla JS array or an immutableJS array, consisting of objects with the following attributes:
```js
{
id: 1,
group: 1,
title: 'Random title',
start_time: 1457902922261,
end_time: 1457902922261 + 86400000,
canMove: true,
canResize: false,
canChangeGroup: false,
itemProps: {
// these optional attributes are passed to the root <div /> of each item as <div {...itemProps} />
'data-custom-attribute': 'Random content',
'aria-hidden': true,
onDoubleClick: () => { console.log('You clicked double!') },
className: 'weekend',
style: {
background: 'fuchsia'
}
}
}
```
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.
**Note that you need to provide either `defaultTimeStart/End` or `visibleTimeStart/End` for the timeline to function**
## buffer
a number (default to 3) which represents the extra timeline rendered on right and lift of the visible area which the user will scroll through before the time rerenders.
more explication in section [behind the scenes](#behind-the-scenes)
Note: setting buffer to 1 will disable the scrolling on the timeline
## selected
An array with id's corresponding to id's in items (`item.id`). If this prop is set you have to manage the selected items yourself within the `onItemSelect` handler to update the property with new id's and use `onItemDeselect` handler to clear selection. This overwrites the default behaviour of selecting one item on click.
## keys
An array specifying keys in the `items` and `groups` objects. Defaults to
```js
{
groupIdKey: 'id',
groupTitleKey: 'title',
groupRightTitleKey: 'rightTitle',
itemIdKey: 'id',
itemTitleKey: 'title', // key for item div content
itemDivTitleKey: 'title', // key for item div title (<div title="text"/>)
itemGroupKey: 'group',
itemTimeStartKey: 'start_time',
itemTimeEndKey: 'end_time',
}
```
## className
Additional class names as a string for the root Timeline element.
## sidebarWidth
Width of the sidebar in pixels. If set to `0`, the sidebar is not rendered. Defaults to `150`.
## sidebarContent
Everything passed here will be displayed above the left sidebar. Use this to display small filters or so. Defaults to `null`.
## rightSidebarWidth
Width of the right sidebar in pixels. If set to `0`, the right sidebar is not rendered. Defaults to `0`.
## rightSidebarContent
Everything passed here will be displayed above the right sidebar. Use this to display small filters or so. Defaults to `null`.
## dragSnap
Snapping unit when dragging items. Defaults to `15 * 60 * 1000` or 15min. When so, the items will snap to 15min intervals when dragging.
## minResizeWidth
The minimum width, in pixels, of a timeline entry when it's possible to resize. If not reached, you must zoom in to resize more. Default to `20`.
## lineHeight
Height of one line in the calendar in pixels. Default `30`
## itemHeightRatio
What percentage of the height of the line is taken by the item? Default `0.65`
## minZoom
Smallest time the calendar can zoom to in milliseconds. Default `60 * 60 * 1000` (1 hour)
__notes__: please note than second won't show up unless you change this to `60 * 1000`
## maxZoom
Largest time the calendar can zoom to in milliseconds. Default `5 * 365.24 * 86400 * 1000` (5 years)
## clickTolerance
How many pixels we can drag the background for it to be counted as a click on the background. Default `3`
## canMove
Can items be dragged around? Can be overridden in the `items` array. Defaults to `true`
## canChangeGroup
Can items be moved between groups? Can be overridden in the `items` array. Defaults to `true`
## canResize
Can items be resized? Can be overridden in the `items` array. Accepted values: `false`, `"left"`, `"right"`, `"both"`. Defaults to `"right"`. If you pass `true`, it will be treated as `"right"` to not break compatibility with versions 0.9 and below.
## useResizeHandle
Append a special `.rct-drag-right` handle to the elements and only resize if dragged from there. Defaults to `false`
### stackItems
Stack items under each other, so there is no visual overlap when times collide. Can be overridden in the `groups` array. Defaults to `false`. Requires millisecond or `Moment` timestamps, not native JavaScript `Date` objects.
## traditionalZoom
Zoom in when scrolling the mouse up/down. Defaults to `false`
## itemTouchSendsClick
Normally tapping (touching) an item selects it. If this is set to true, a tap will have the same effe
没有合适的资源?快使用搜索试试~ 我知道了~
现代且响应迅速的React时间轴组件。_JavaScript_SCSS_下载.zip
共139个文件
js:105个
snap:10个
md:8个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 70 浏览量
2023-04-21
10:36:16
上传
评论
收藏 2.88MB ZIP 举报
温馨提示
现代且响应迅速的React时间轴组件。_JavaScript_SCSS_下载
资源推荐
资源详情
资源评论
收起资源包目录
现代且响应迅速的React时间轴组件。_JavaScript_SCSS_下载.zip (139个子文件)
.babelrc 411B
.editorconfig 117B
deploy-travis-key.enc 2KB
.eslintrc 596B
demo.gif 2.5MB
.gitignore 167B
index.html 412B
Timeline.js 30KB
calendar.js 19KB
Item.js 19KB
DateHeader.test.js 16KB
CustomHeader.test.js 12KB
index.js 11KB
TimelineHeader.test.js 8KB
index.js 7KB
ScrollElement.test.js 7KB
index.js 6KB
CustomMarker.test.js 6KB
index.js 6KB
CustomHeader.js 6KB
ScrollElement.js 6KB
Items.js 6KB
index.js 5KB
index.js 5KB
index.js 5KB
SideBarHeader.test.js 5KB
index.js 5KB
headerRenderers.js 5KB
CursorMarker.test.js 5KB
PreventClickOnDrag.js 4KB
TimelineHeaders.js 4KB
DateHeader.js 4KB
stack-items.js 4KB
index.js 4KB
Columns.js 3KB
index.js 3KB
index.js 3KB
get-item-with-interactions.js 3KB
calculate-scroll-canvas.js 3KB
get-visible-items.js 3KB
TimelineStateContext.js 3KB
index.js 3KB
index.js 3KB
MarkerCanvas.js 3KB
TodayMarker.test.js 2KB
TimelineMarkersRenderer.js 2KB
CursorMarker.js 2KB
Sidebar.js 2KB
collision.js 2KB
groupOrderAndItemDimentions.js 2KB
GroupRow.test.js 2KB
index.js 2KB
calculate-dimensions.js 2KB
TimelineMarkersContext.js 2KB
Interval.js 2KB
Timeline.test.js 2KB
get-min-unit.js 2KB
generate-fake-data.js 2KB
GroupRows.js 2KB
SidebarHeader.js 2KB
calculate-time-for-x-position.js 2KB
calculate-interaction-new-times.js 2KB
TodayMarker.js 2KB
defaultHeaders.js 2KB
header-renderer.js 1KB
CustomMarker.js 1KB
TodayMarker.js 1KB
dom-helpers.js 1KB
TimelineMarkers.test.js 1KB
GroupRow.js 1KB
stateAndProps.js 1KB
webpack.config.js 1KB
HeadersContext.js 1KB
marker-renderer.js 1KB
default-config.js 1KB
calculate-x-position-for-time.js 1KB
CustomDateHeader.js 1KB
CursorMarker.js 1KB
Sidebar.test.js 1KB
styles.js 1012B
itemsAndGroups.js 998B
PreventClickOnDrag.js 938B
CustomInfoLabel.js 929B
GroupRows.test.js 908B
get-next-unit.js 905B
defaultItemRenderer.js 880B
CustomMarker.js 832B
shared.js 803B
get-item-dimensions.js 793B
generic.js 777B
index.js 647B
container.js 604B
TimelineMarkers.js 478B
stack-all.js 475B
group-stack.js 426B
stack-group.js 418B
group-no-stack.js 416B
MarkerCanvasContext.js 408B
coordinate-to-time-ratio.js 403B
jest-setup.js 384B
共 139 条
- 1
- 2
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9156
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功