Skip to content

refactor:timeline #6263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 components/input/style/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ const genTextAreaStyle: GenerateStyle<InputToken> = token => {
[`> ${componentCls}`]: {
height: '100%',
},

'&::after': {
color: token.colorTextDescription,
whiteSpace: 'nowrap',
Expand Down
2 changes: 1 addition & 1 deletion components/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import './date-picker/style';
import './slider/style';
import './table/style';
// import './progress/style';
import './timeline/style';
// import './timeline/style';
import './input-number/style';
// import './transfer/style';
import './tree/style';
Expand Down
4 changes: 2 additions & 2 deletions components/theme/interface/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import type { ComponentToken as SpinComponentToken } from '../../spin/style';
// import type { ComponentToken as TableComponentToken } from '../../table/style';
// import type { ComponentToken as TabsComponentToken } from '../../tabs/style';
import type { ComponentToken as TagComponentToken } from '../../tag/style';
// import type { ComponentToken as TimelineComponentToken } from '../../timeline/style';
import type { ComponentToken as TimelineComponentToken } from '../../timeline/style';
import type { ComponentToken as TooltipComponentToken } from '../../tooltip/style';
import type { ComponentToken as TransferComponentToken } from '../../transfer/style';
import type { ComponentToken as TypographyComponentToken } from '../../typography/style';
Expand Down Expand Up @@ -99,7 +99,7 @@ export interface ComponentTokenMap {
Tree?: {};
TreeSelect?: {};
Typography?: TypographyComponentToken;
// Timeline?: TimelineComponentToken;
Timeline?: TimelineComponentToken;
Transfer?: TransferComponentToken;
// Tabs?: TabsComponentToken;
// Calendar?: CalendarComponentToken;
Expand Down
39 changes: 28 additions & 11 deletions components/timeline/Timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ import { filterEmpty } from '../_util/props-util';
import initDefaultProps from '../_util/props-util/initDefaultProps';
import TimelineItem from './TimelineItem';
import LoadingOutlined from '@ant-design/icons-vue/LoadingOutlined';
import { tuple } from '../_util/type';
import { tuple, booleanType } from '../_util/type';
import useConfigInject from '../config-provider/hooks/useConfigInject';

// CSSINJS
import useStyle from './style';

export const timelineProps = () => ({
prefixCls: String,
/** 指定最后一个幽灵节点是否存在或内容 */
pending: PropTypes.any,
pendingDot: PropTypes.any,
reverse: { type: Boolean, default: undefined },
reverse: booleanType(),
mode: PropTypes.oneOf(tuple('left', 'alternate', 'right', '')),
});

Expand All @@ -23,13 +26,18 @@ export type TimelineProps = Partial<ExtractPropTypes<ReturnType<typeof timelineP
export default defineComponent({
compatConfig: { MODE: 3 },
name: 'ATimeline',
inheritAttrs: false,
props: initDefaultProps(timelineProps(), {
reverse: false,
mode: '',
}),
slots: ['pending', 'pendingDot'],
setup(props, { slots }) {
setup(props, { slots, attrs }) {
const { prefixCls, direction } = useConfigInject('timeline', props);

// style
const [wrapSSR, hashId] = useStyle(prefixCls);

const getPositionCls = (ele, idx: number) => {
const eleProps = ele.props || {};
if (props.mode === 'alternate') {
Expand Down Expand Up @@ -80,14 +88,23 @@ export default defineComponent({
const hasLabelItem = timeLineItems.some(
item => !!(item.props?.label || item.children?.label),
);
const classString = classNames(prefixCls.value, {
[`${prefixCls.value}-pending`]: !!pending,
[`${prefixCls.value}-reverse`]: !!reverse,
[`${prefixCls.value}-${mode}`]: !!mode && !hasLabelItem,
[`${prefixCls.value}-label`]: hasLabelItem,
[`${prefixCls.value}-rtl`]: direction.value === 'rtl',
});
return <ul class={classString}>{items}</ul>;
const classString = classNames(
prefixCls.value,
{
[`${prefixCls.value}-pending`]: !!pending,
[`${prefixCls.value}-reverse`]: !!reverse,
[`${prefixCls.value}-${mode}`]: !!mode && !hasLabelItem,
[`${prefixCls.value}-label`]: hasLabelItem,
[`${prefixCls.value}-rtl`]: direction.value === 'rtl',
},
attrs.class,
hashId.value,
);
return wrapSSR(
<ul {...attrs} class={classString}>
{items}
</ul>,
);
};
},
});
4 changes: 2 additions & 2 deletions components/timeline/TimelineItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { defineComponent } from 'vue';
import classNames from '../_util/classNames';
import PropTypes from '../_util/vue-types';
import initDefaultProps from '../_util/props-util/initDefaultProps';
import { tuple } from '../_util/type';
import { tuple, booleanType } from '../_util/type';
import useConfigInject from '../config-provider/hooks/useConfigInject';

export const timelineItemProps = () => ({
prefixCls: String,
color: String,
dot: PropTypes.any,
pending: { type: Boolean, default: undefined },
pending: booleanType(),
position: PropTypes.oneOf(tuple('left', 'right', '')).def(''),
label: PropTypes.any,
});
Expand Down
2 changes: 1 addition & 1 deletion components/timeline/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
category: Components
type: Data Display
title: Timeline
cover: https://gw.alipayobjects.com/zos/antfincdn/vJmo00mmgR/Timeline.svg
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*FkTySqNt3sYAAAAAAAAAAAAADrJ8AQ/original
---

Vertical display timeline.
Expand Down
2 changes: 1 addition & 1 deletion components/timeline/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ category: Components
type: 数据展示
title: Timeline
subtitle: 时间轴
cover: https://gw.alipayobjects.com/zos/antfincdn/vJmo00mmgR/Timeline.svg
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*FkTySqNt3sYAAAAAAAAAAAAADrJ8AQ/original
---

垂直展示的时间流信息。
Expand Down
185 changes: 0 additions & 185 deletions components/timeline/style/index.less

This file was deleted.

Loading