Skip to content

Commit 587c1ca

Browse files
authored
refactor:timeline (#6263)
* refactor:timeline * docs:update & refactor: timeline type
1 parent 8a233d7 commit 587c1ca

File tree

10 files changed

+273
-341
lines changed

10 files changed

+273
-341
lines changed

components/input/style/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ const genTextAreaStyle: GenerateStyle<InputToken> = token => {
904904
[`> ${componentCls}`]: {
905905
height: '100%',
906906
},
907-
907+
908908
'&::after': {
909909
color: token.colorTextDescription,
910910
whiteSpace: 'nowrap',

components/style.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import './calendar/style';
3939
// import './slider/style';
4040
import './table/style';
4141
// import './progress/style';
42-
import './timeline/style';
42+
// import './timeline/style';
4343
import './input-number/style';
4444
// import './transfer/style';
4545
import './tree/style';

components/theme/interface/components.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import type { ComponentToken as SpinComponentToken } from '../../spin/style';
4040
// import type { ComponentToken as TableComponentToken } from '../../table/style';
4141
// import type { ComponentToken as TabsComponentToken } from '../../tabs/style';
4242
import type { ComponentToken as TagComponentToken } from '../../tag/style';
43-
// import type { ComponentToken as TimelineComponentToken } from '../../timeline/style';
43+
import type { ComponentToken as TimelineComponentToken } from '../../timeline/style';
4444
import type { ComponentToken as TooltipComponentToken } from '../../tooltip/style';
4545
import type { ComponentToken as TransferComponentToken } from '../../transfer/style';
4646
import type { ComponentToken as TypographyComponentToken } from '../../typography/style';
@@ -99,7 +99,7 @@ export interface ComponentTokenMap {
9999
Tree?: {};
100100
TreeSelect?: {};
101101
Typography?: TypographyComponentToken;
102-
// Timeline?: TimelineComponentToken;
102+
Timeline?: TimelineComponentToken;
103103
Transfer?: TransferComponentToken;
104104
// Tabs?: TabsComponentToken;
105105
// Calendar?: CalendarComponentToken;

components/timeline/Timeline.tsx

+28-11
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ import { filterEmpty } from '../_util/props-util';
66
import initDefaultProps from '../_util/props-util/initDefaultProps';
77
import TimelineItem from './TimelineItem';
88
import LoadingOutlined from '@ant-design/icons-vue/LoadingOutlined';
9-
import { tuple } from '../_util/type';
9+
import { tuple, booleanType } from '../_util/type';
1010
import useConfigInject from '../config-provider/hooks/useConfigInject';
1111

12+
// CSSINJS
13+
import useStyle from './style';
14+
1215
export const timelineProps = () => ({
1316
prefixCls: String,
1417
/** 指定最后一个幽灵节点是否存在或内容 */
1518
pending: PropTypes.any,
1619
pendingDot: PropTypes.any,
17-
reverse: { type: Boolean, default: undefined },
20+
reverse: booleanType(),
1821
mode: PropTypes.oneOf(tuple('left', 'alternate', 'right', '')),
1922
});
2023

@@ -23,13 +26,18 @@ export type TimelineProps = Partial<ExtractPropTypes<ReturnType<typeof timelineP
2326
export default defineComponent({
2427
compatConfig: { MODE: 3 },
2528
name: 'ATimeline',
29+
inheritAttrs: false,
2630
props: initDefaultProps(timelineProps(), {
2731
reverse: false,
2832
mode: '',
2933
}),
3034
slots: ['pending', 'pendingDot'],
31-
setup(props, { slots }) {
35+
setup(props, { slots, attrs }) {
3236
const { prefixCls, direction } = useConfigInject('timeline', props);
37+
38+
// style
39+
const [wrapSSR, hashId] = useStyle(prefixCls);
40+
3341
const getPositionCls = (ele, idx: number) => {
3442
const eleProps = ele.props || {};
3543
if (props.mode === 'alternate') {
@@ -80,14 +88,23 @@ export default defineComponent({
8088
const hasLabelItem = timeLineItems.some(
8189
item => !!(item.props?.label || item.children?.label),
8290
);
83-
const classString = classNames(prefixCls.value, {
84-
[`${prefixCls.value}-pending`]: !!pending,
85-
[`${prefixCls.value}-reverse`]: !!reverse,
86-
[`${prefixCls.value}-${mode}`]: !!mode && !hasLabelItem,
87-
[`${prefixCls.value}-label`]: hasLabelItem,
88-
[`${prefixCls.value}-rtl`]: direction.value === 'rtl',
89-
});
90-
return <ul class={classString}>{items}</ul>;
91+
const classString = classNames(
92+
prefixCls.value,
93+
{
94+
[`${prefixCls.value}-pending`]: !!pending,
95+
[`${prefixCls.value}-reverse`]: !!reverse,
96+
[`${prefixCls.value}-${mode}`]: !!mode && !hasLabelItem,
97+
[`${prefixCls.value}-label`]: hasLabelItem,
98+
[`${prefixCls.value}-rtl`]: direction.value === 'rtl',
99+
},
100+
attrs.class,
101+
hashId.value,
102+
);
103+
return wrapSSR(
104+
<ul {...attrs} class={classString}>
105+
{items}
106+
</ul>,
107+
);
91108
};
92109
},
93110
});

components/timeline/TimelineItem.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { defineComponent } from 'vue';
33
import classNames from '../_util/classNames';
44
import PropTypes from '../_util/vue-types';
55
import initDefaultProps from '../_util/props-util/initDefaultProps';
6-
import { tuple } from '../_util/type';
6+
import { tuple, booleanType } from '../_util/type';
77
import useConfigInject from '../config-provider/hooks/useConfigInject';
88

99
export const timelineItemProps = () => ({
1010
prefixCls: String,
1111
color: String,
1212
dot: PropTypes.any,
13-
pending: { type: Boolean, default: undefined },
13+
pending: booleanType(),
1414
position: PropTypes.oneOf(tuple('left', 'right', '')).def(''),
1515
label: PropTypes.any,
1616
});

components/timeline/index.en-US.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
category: Components
33
type: Data Display
44
title: Timeline
5-
cover: https://gw.alipayobjects.com/zos/antfincdn/vJmo00mmgR/Timeline.svg
5+
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*FkTySqNt3sYAAAAAAAAAAAAADrJ8AQ/original
66
---
77

88
Vertical display timeline.

components/timeline/index.zh-CN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ category: Components
33
type: 数据展示
44
title: Timeline
55
subtitle: 时间轴
6-
cover: https://gw.alipayobjects.com/zos/antfincdn/vJmo00mmgR/Timeline.svg
6+
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*FkTySqNt3sYAAAAAAAAAAAAADrJ8AQ/original
77
---
88

99
垂直展示的时间流信息。

components/timeline/style/index.less

-185
This file was deleted.

0 commit comments

Comments
 (0)