2022-05-09 22:20:07 +08:00
|
|
|
import type { CSSObject } from '@ant-design/cssinjs';
|
2022-11-23 20:22:38 +08:00
|
|
|
import type { FullToken, GenerateStyle } from '../../theme/internal';
|
|
|
|
import { genComponentStyleHook, mergeToken } from '../../theme/internal';
|
2022-07-11 15:35:58 +08:00
|
|
|
import { resetComponent } from '../../style';
|
2022-04-12 00:17:57 +08:00
|
|
|
|
|
|
|
export interface ComponentToken {}
|
|
|
|
|
2022-05-24 12:03:16 +08:00
|
|
|
interface TimelineToken extends FullToken<'Timeline'> {
|
|
|
|
timeLineItemPaddingBottom: number;
|
|
|
|
timeLineItemHeadSize: number;
|
|
|
|
timeLineItemCustomHeadPaddingVertical: number;
|
2022-09-08 15:53:00 +08:00
|
|
|
timeLineItemTailWidth: number;
|
2022-05-24 12:03:16 +08:00
|
|
|
timeLinePaddingInlineEnd: number;
|
2022-09-13 11:52:56 +08:00
|
|
|
timeLineHeadBorderWidth: number;
|
2022-05-24 12:03:16 +08:00
|
|
|
}
|
2022-04-12 00:17:57 +08:00
|
|
|
|
2022-11-19 13:47:33 +08:00
|
|
|
const genTimelineStyle: GenerateStyle<TimelineToken, CSSObject> = (token) => {
|
2022-04-12 00:17:57 +08:00
|
|
|
const { componentCls } = token;
|
|
|
|
|
|
|
|
return {
|
|
|
|
[componentCls]: {
|
|
|
|
...resetComponent(token),
|
|
|
|
margin: 0,
|
|
|
|
padding: 0,
|
|
|
|
listStyle: 'none',
|
|
|
|
|
|
|
|
[`${componentCls}-item`]: {
|
|
|
|
position: 'relative',
|
|
|
|
margin: 0,
|
2022-05-24 12:03:16 +08:00
|
|
|
paddingBottom: token.timeLineItemPaddingBottom,
|
|
|
|
fontSize: token.fontSize,
|
2022-04-12 00:17:57 +08:00
|
|
|
listStyle: 'none',
|
|
|
|
|
|
|
|
'&-tail': {
|
|
|
|
position: 'absolute',
|
2022-05-24 12:03:16 +08:00
|
|
|
insetBlockStart: token.timeLineItemHeadSize,
|
2022-09-08 15:53:00 +08:00
|
|
|
insetInlineStart: (token.timeLineItemHeadSize - token.timeLineItemTailWidth) / 2,
|
2022-05-24 12:03:16 +08:00
|
|
|
height: `calc(100% - ${token.timeLineItemHeadSize}px)`,
|
2022-09-08 15:53:00 +08:00
|
|
|
borderInlineStart: `${token.timeLineItemTailWidth}px ${token.lineType} ${token.colorSplit}`,
|
2022-04-12 00:17:57 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'&-pending': {
|
|
|
|
[`${componentCls}-item-head`]: {
|
|
|
|
fontSize: token.fontSizeSM,
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-item-tail`]: {
|
|
|
|
display: 'none',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-head': {
|
|
|
|
position: 'absolute',
|
2022-05-24 12:03:16 +08:00
|
|
|
width: token.timeLineItemHeadSize,
|
|
|
|
height: token.timeLineItemHeadSize,
|
2022-06-28 20:33:01 +08:00
|
|
|
backgroundColor: token.colorBgContainer,
|
2022-09-13 11:52:56 +08:00
|
|
|
border: `${token.timeLineHeadBorderWidth}px ${token.lineType} transparent`,
|
2022-05-24 12:03:16 +08:00
|
|
|
borderRadius: '50%',
|
2022-04-12 00:17:57 +08:00
|
|
|
|
|
|
|
'&-blue': {
|
|
|
|
color: token.colorPrimary,
|
|
|
|
borderColor: token.colorPrimary,
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-red': {
|
|
|
|
color: token.colorError,
|
|
|
|
borderColor: token.colorError,
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-green': {
|
|
|
|
color: token.colorSuccess,
|
|
|
|
borderColor: token.colorSuccess,
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-gray': {
|
|
|
|
color: token.colorTextDisabled,
|
|
|
|
borderColor: token.colorTextDisabled,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-head-custom': {
|
|
|
|
position: 'absolute',
|
2022-05-24 12:03:16 +08:00
|
|
|
insetBlockStart: token.timeLineItemHeadSize / 2,
|
|
|
|
insetInlineStart: token.timeLineItemHeadSize / 2,
|
2022-04-12 00:17:57 +08:00
|
|
|
width: 'auto',
|
|
|
|
height: 'auto',
|
|
|
|
marginBlockStart: 0,
|
2022-05-24 12:03:16 +08:00
|
|
|
paddingBlock: token.timeLineItemCustomHeadPaddingVertical,
|
2022-04-12 00:17:57 +08:00
|
|
|
lineHeight: 1,
|
|
|
|
textAlign: 'center',
|
|
|
|
border: 0,
|
|
|
|
borderRadius: 0,
|
|
|
|
transform: `translate(-50%, -50%)`,
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-content': {
|
|
|
|
position: 'relative',
|
2022-05-24 12:03:16 +08:00
|
|
|
insetBlockStart: -(token.fontSize * token.lineHeight - token.fontSize) + token.lineWidth,
|
|
|
|
marginInlineStart: token.margin + token.timeLineItemHeadSize,
|
2022-04-19 11:27:09 +08:00
|
|
|
marginInlineEnd: 0,
|
|
|
|
marginBlockStart: 0,
|
|
|
|
marginBlockEnd: 0,
|
2022-04-12 00:17:57 +08:00
|
|
|
wordBreak: 'break-word',
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-last': {
|
|
|
|
[`> ${componentCls}-item-tail`]: {
|
|
|
|
display: 'none',
|
|
|
|
},
|
|
|
|
|
|
|
|
[`> ${componentCls}-item-content`]: {
|
2022-05-24 12:03:16 +08:00
|
|
|
minHeight: token.controlHeightLG * 1.2,
|
2022-04-12 00:17:57 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`&${componentCls}-alternate,
|
|
|
|
&${componentCls}-right,
|
|
|
|
&${componentCls}-label`]: {
|
|
|
|
[`${componentCls}-item`]: {
|
|
|
|
'&-tail, &-head, &-head-custom': {
|
|
|
|
insetInlineStart: '50%',
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-head': {
|
|
|
|
marginInlineStart: `-${token.marginXXS}px`,
|
|
|
|
|
|
|
|
'&-custom': {
|
2022-09-08 15:53:00 +08:00
|
|
|
marginInlineStart: token.timeLineItemTailWidth / 2,
|
2022-04-12 00:17:57 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-left': {
|
|
|
|
[`${componentCls}-item-content`]: {
|
|
|
|
insetInlineStart: `calc(50% - ${token.marginXXS}px)`,
|
2022-05-24 12:03:16 +08:00
|
|
|
width: `calc(50% - ${token.marginSM}px)`,
|
2022-04-12 00:17:57 +08:00
|
|
|
textAlign: 'start',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-right': {
|
|
|
|
[`${componentCls}-item-content`]: {
|
|
|
|
width: `calc(50% - ${token.marginSM}px)`,
|
|
|
|
margin: 0,
|
|
|
|
textAlign: 'end',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`&${componentCls}-right`]: {
|
|
|
|
[`${componentCls}-item-right`]: {
|
|
|
|
[`${componentCls}-item-tail,
|
|
|
|
${componentCls}-item-head,
|
|
|
|
${componentCls}-item-head-custom`]: {
|
2022-05-24 12:03:16 +08:00
|
|
|
insetInlineStart: `calc(100% - ${token.timeLinePaddingInlineEnd}px)`,
|
2022-04-12 00:17:57 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-item-content`]: {
|
2022-05-24 12:03:16 +08:00
|
|
|
width: `calc(100% - ${token.timeLineItemHeadSize + token.marginXS}px)`,
|
2022-04-12 00:17:57 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`&${componentCls}-pending
|
|
|
|
${componentCls}-item-last
|
|
|
|
${componentCls}-item-tail`]: {
|
|
|
|
display: 'block',
|
2022-05-24 12:03:16 +08:00
|
|
|
height: `calc(100% - ${token.margin}px)`,
|
2022-09-08 15:53:00 +08:00
|
|
|
borderInlineStart: `${token.timeLineItemTailWidth}px dotted ${token.colorSplit}`,
|
2022-04-12 00:17:57 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
[`&${componentCls}-reverse
|
|
|
|
${componentCls}-item-last
|
|
|
|
${componentCls}-item-tail`]: {
|
|
|
|
display: 'none',
|
|
|
|
},
|
|
|
|
|
|
|
|
[`&${componentCls}-reverse ${componentCls}-item-pending`]: {
|
|
|
|
[`${componentCls}-item-tail`]: {
|
2022-05-24 12:03:16 +08:00
|
|
|
insetBlockStart: token.margin,
|
2022-04-12 00:17:57 +08:00
|
|
|
display: 'block',
|
2022-05-24 12:03:16 +08:00
|
|
|
height: `calc(100% - ${token.margin}px)`,
|
2022-09-08 15:53:00 +08:00
|
|
|
borderInlineStart: `${token.timeLineItemTailWidth}px dotted ${token.colorSplit}`,
|
2022-04-12 00:17:57 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-item-content`]: {
|
2022-05-24 12:03:16 +08:00
|
|
|
minHeight: token.controlHeightLG * 1.2,
|
2022-04-12 00:17:57 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`&${componentCls}-label`]: {
|
|
|
|
[`${componentCls}-item-label`]: {
|
|
|
|
position: 'absolute',
|
2022-09-08 15:53:00 +08:00
|
|
|
insetBlockStart:
|
2022-11-01 15:06:38 +08:00
|
|
|
-(token.fontSize * token.lineHeight - token.fontSize) + token.timeLineItemTailWidth,
|
2022-04-12 00:17:57 +08:00
|
|
|
width: `calc(50% - ${token.marginSM}px)`,
|
|
|
|
textAlign: 'end',
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-item-right`]: {
|
|
|
|
[`${componentCls}-item-label`]: {
|
2022-05-24 12:03:16 +08:00
|
|
|
insetInlineStart: `calc(50% + ${token.marginSM}px)`,
|
|
|
|
width: `calc(50% - ${token.marginSM}px)`,
|
2022-04-12 00:17:57 +08:00
|
|
|
textAlign: 'start',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// ============================== Export ==============================
|
2022-11-19 13:47:33 +08:00
|
|
|
export default genComponentStyleHook('Timeline', (token) => {
|
2022-05-24 12:03:16 +08:00
|
|
|
const timeLineToken = mergeToken<TimelineToken>(token, {
|
|
|
|
timeLineItemPaddingBottom: token.padding * 1.25,
|
|
|
|
timeLineItemHeadSize: 10,
|
|
|
|
timeLineItemCustomHeadPaddingVertical: token.paddingXXS,
|
|
|
|
timeLinePaddingInlineEnd: 2,
|
2022-09-08 15:53:00 +08:00
|
|
|
timeLineItemTailWidth: token.lineWidthBold,
|
2022-09-13 11:52:56 +08:00
|
|
|
timeLineHeadBorderWidth: token.wireframe ? token.lineWidthBold : token.lineWidth * 3,
|
2022-05-24 12:03:16 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
return [genTimelineStyle(timeLineToken)];
|
|
|
|
});
|