Timeline 时间轴

如果项目中使用的是 0.x 版本的基础组件(@icedesign/base, @ali/ice, @alife/next),请在左侧导航顶部切换组件版本。

安装方法

  1. 在命令行中执行以下命令npm install @alifd/next@latest -S

Guide

垂直展示的时间流信息。

何时使用

  • 当有一系列信息需要从上至下按时间排列时。

  • 需要有一条时间轴进行视觉上的串联时。

API

Timeline

参数说明类型默认值
fold自定义折叠选项 示例[{foldArea: [startIndex, endIndex], foldShow: boolean}]Array[]

Timeline.Item

参数说明类型默认值
state节点状态可选值:'done', 'process', 'error', 'success'Enum'done'
icon图标String-
dot自定义时间轴节点ReactNode-
time格式化后的时间ReactNode-
title标题ReactNode-
timeLeft左侧时间ReactNode-
content右侧内容ReactNode-
animation动画Booleantrue

代码示例

基本

最简单的用法。

Timeline 时间轴 - 图1

查看源码在线预览

  1. import { Timeline } from '@alifd/next';
  2. const TimelineItem = Timeline.Item;
  3. ReactDOM.render(<Timeline>
  4. <TimelineItem title="Receipt" state="process"/>
  5. <TimelineItem title="Ship" />
  6. <TimelineItem title="Order" />
  7. </Timeline>, mountNode);

状态

设置每个节点不同的状态。

Timeline 时间轴 - 图2

查看源码在线预览

  1. import { Timeline } from '@alifd/next';
  2. const TimelineItem = Timeline.Item;
  3. ReactDOM.render(<Timeline>
  4. <TimelineItem title="Cloudy" time={'2016-06-10 10:30:00'} state="process"/>
  5. <TimelineItem title="Sunny" time={'2016-06-11'} state="success"/>
  6. <TimelineItem title="Rainy" time={'2016-06-09'} state="error"/>
  7. </Timeline>, mountNode);

内容

带内容的用法,分别添加title,content,icon的效果。

Timeline 时间轴 - 图3

查看源码在线预览

  1. import { Timeline } from '@alifd/next';
  2. const TimelineItem = Timeline.Item;
  3. ReactDOM.render(<Timeline>
  4. <TimelineItem title="Sign" content="[Hangzhou] has received the sign, the signer is Alibaba Post Office, thank you for using STO, looking forward to serving you again" time={'2016-06-10 10:30:00'} state="process" />
  5. <TimelineItem title="Delivery" content="[Hangzhou]Express has reached Hangzhou Hangzhou Binjiang Company" time={'2016-06-10 09:30:00'} />
  6. <TimelineItem title="Delivery" content="[Hangzhou] Zhejiang Hangzhou Binjiang Company dispatches members for you" time={'2016-06-10 09:03:00'} />
  7. <TimelineItem title="Transport" content="[Hangzhou] Zhejiang Hangzhou Transshipment Center has been issued" time={'2016-06-10 06:10:00'} />
  8. <TimelineItem title="Transport" content="[Dongguan City] Guangdong Dongguan Transshipment Center has been issued" time={'2016-06-09 18:00:00'} />
  9. <TimelineItem title="Processing" content="[Dongguan City] Shentong Express Guangdong Fenggang Branch of Guangdong Province" time={'2016-06-09 16:12:00'} />
  10. <TimelineItem title="Processing" content="[Dongguan City] The merchant is informing the express company to insert" time={'2016-06-09 14:00:00'} />
  11. <TimelineItem title="Processing" content="[Dongguan City] Your order to be picked" time={'2016-06-09 10:12:19'} />
  12. <TimelineItem title="Processing" content="[Dongguan] Your order starts processing" time={'2016-06-09 10:01:09'} icon="atm"/>
  13. </Timeline>, mountNode);

时间在左

设置时间轴左边的内容。

Timeline 时间轴 - 图4

查看源码在线预览

  1. import { Timeline } from '@alifd/next';
  2. const TimelineItem = Timeline.Item;
  3. ReactDOM.render(<Timeline>
  4. <TimelineItem title="Sign" state="process" timeLeft="2016-10-03" />
  5. <TimelineItem title="Ship" timeLeft="2016-10-02" />
  6. <TimelineItem title="Order" timeLeft="2016-10-01" />
  7. </Timeline>, mountNode);

自定义时间轴节点

自定义时间轴节点。

Timeline 时间轴 - 图5

查看源码在线预览

  1. import { Timeline, Icon } from '@alifd/next';
  2. const TimelineItem = Timeline.Item;
  3. ReactDOM.render(<Timeline>
  4. <TimelineItem title="Receipt" state="process" icon="smile" time="2017-10-21"/>
  5. <TimelineItem title="Ship" dot={<span className="custom-node"> 😂 </span>} state="success" time="2017-10-22"/>
  6. <TimelineItem title="Order" dot={<Icon type="success" size="xl" style={{ color: '#1DC11D' }}/>} content="Congratulations, successful orders!" time="2017-10-23"/>
  7. </Timeline>, mountNode);
  1. .custom-node {
  2. color: #1DC11D;
  3. position: relative;
  4. left: 3px;
  5. font-size: 14px;
  6. }

折叠

自定义折叠区域。

Timeline 时间轴 - 图6

查看源码在线预览

  1. import { Timeline, Select } from '@alifd/next';
  2. const TimelineItem = Timeline.Item;
  3. class Demo extends React.Component {
  4. constructor(props) {
  5. super(props);
  6. this.state = {
  7. timelineAnimation: true
  8. };
  9. }
  10. onTimelineAnimation = (value) => {
  11. this.setState({ timelineAnimation: value });
  12. }
  13. render() {
  14. return (<div>
  15. <div className="custom-step-option">
  16. <Select placeholder="Whether to start animation" onChange={this.onTimelineAnimation} className="custom-select" defaultValue>
  17. {
  18. [true, false].map((item, index) => <Select.Option value={item} key={index}>{item ? 'Animation on' : 'Animation off'}</Select.Option>)
  19. }
  20. </Select>
  21. </div>
  22. <Timeline animation={this.state.timelineAnimation} fold={[{ foldArea: [1, 2], foldShow: false }, { foldArea: [5], foldShow: false }]}>
  23. <TimelineItem title="Sign" content="[Hangzhou] has received the sign, the signer is Alibaba Post Office, thank you for using STO, looking forward to serving you again" time={'2016-06-10 10:30:00'} state="process" />
  24. <TimelineItem title="Delivery" content="[Hangzhou]Express has reached Hangzhou Hangzhou Binjiang Company" time={'2016-06-10 09:30:00'} />
  25. <TimelineItem title="Delivery" content="[Hangzhou] Zhejiang Hangzhou Binjiang Company dispatches members for you" time={'2016-06-10 09:03:00'} />
  26. <TimelineItem title="Transport" content="[Hangzhou] Zhejiang Hangzhou Transshipment Center has been issued" time={'2016-06-10 06:10:00'} />
  27. <TimelineItem title="Transport" content="[Dongguan City] Guangdong Dongguan Transshipment Center has been issued" time={'2016-06-09 18:00:00'} />
  28. <TimelineItem title="Processing" content="[Dongguan City] Shentong Express Guangdong Fenggang Branch of Guangdong Province" time={'2016-06-09 16:12:00'} />
  29. <TimelineItem title="Processing" content="[Dongguan City] The merchant is informing the express company to insert" time={'2016-06-09 14:00:00'} />
  30. <TimelineItem title="Processing" content="[Dongguan City] Your order to be picked" time={'2016-06-09 10:12:19'} />
  31. <TimelineItem title="Processing" content="[Dongguan] Your order starts processing" time={'2016-06-09 10:01:09'} />
  32. </Timeline>
  33. </div>);
  34. }
  35. }
  36. ReactDOM.render(<Demo />, mountNode);
  1. .custom-step-option {
  2. margin-bottom: 20px;
  3. }

相关区块

Timeline 时间轴 - 图7

暂无相关区块