2022-04-19 11:28:06 +08:00
|
|
|
import type { CSSObject } from '@ant-design/cssinjs';
|
2022-06-27 14:25:59 +08:00
|
|
|
import type { FullToken, GenerateStyle } from '../../theme';
|
|
|
|
import { genComponentStyleHook, mergeToken, resetComponent } from '../../theme';
|
2022-04-19 11:28:06 +08:00
|
|
|
import genStepsCustomIconStyle from './custom-icon';
|
|
|
|
import genStepsLabelPlacementStyle from './label-placement';
|
|
|
|
import genStepsNavStyle from './nav';
|
2022-06-01 11:19:05 +08:00
|
|
|
import genStepsProgressStyle from './progress';
|
|
|
|
import genStepsProgressDotStyle from './progress-dot';
|
2022-04-19 11:28:06 +08:00
|
|
|
import genStepsRTLStyle from './rtl';
|
2022-06-01 11:19:05 +08:00
|
|
|
import genStepsSmallStyle from './small';
|
|
|
|
import genStepsVerticalStyle from './vertical';
|
|
|
|
|
|
|
|
export interface ComponentToken {
|
|
|
|
descriptionWidth: number;
|
|
|
|
}
|
2022-04-19 11:28:06 +08:00
|
|
|
|
|
|
|
export interface StepsToken extends FullToken<'Steps'> {
|
|
|
|
// Steps variable default.less
|
|
|
|
processTailColor: string;
|
|
|
|
stepsNavArrowColor: string;
|
|
|
|
stepsIconSize: number;
|
|
|
|
stepsIconCustomSize: number;
|
|
|
|
stepsIconCustomTop: number;
|
|
|
|
stepsIconCustomFontSize: number;
|
|
|
|
stepsIconTop: number;
|
|
|
|
stepsIconFontSize: number;
|
|
|
|
stepsTitleLineHeight: number;
|
|
|
|
stepsSmallIconSize: number;
|
|
|
|
stepsDotSize: number;
|
|
|
|
stepsCurrentDotSize: number;
|
|
|
|
stepsNavContentMaxWidth: string;
|
|
|
|
// Steps component less variable
|
|
|
|
processIconColor: string;
|
|
|
|
processTitleColor: string;
|
|
|
|
processDescriptionColor: string;
|
|
|
|
processIconTextColor: string;
|
|
|
|
waitIconColor: string;
|
|
|
|
waitTitleColor: string;
|
|
|
|
waitDescriptionColor: string;
|
|
|
|
waitTailColor: string;
|
|
|
|
finishIconColor: string;
|
|
|
|
finishTitleColor: string;
|
|
|
|
finishDescriptionColor: string;
|
|
|
|
finishTailColor: string;
|
|
|
|
errorIconColor: string;
|
|
|
|
errorTitleColor: string;
|
|
|
|
errorDescriptionColor: string;
|
|
|
|
errorTailColor: string;
|
|
|
|
stepsNavActiveColor: string;
|
2022-06-01 11:19:05 +08:00
|
|
|
stepsProgressSize: number;
|
2022-04-19 11:28:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
enum StepItemStatusEnum {
|
|
|
|
wait = 'wait',
|
|
|
|
process = 'process',
|
|
|
|
finish = 'finish',
|
|
|
|
error = 'error',
|
|
|
|
}
|
|
|
|
|
|
|
|
const genStepsItemStatusStyle = (status: StepItemStatusEnum, token: StepsToken): CSSObject => {
|
|
|
|
const prefix = `${token.componentCls}-item`;
|
|
|
|
const iconColorKey: keyof StepsToken = `${status}IconColor`;
|
|
|
|
const titleColorKey: keyof StepsToken = `${status}TitleColor`;
|
|
|
|
const descriptionColorKey: keyof StepsToken = `${status}DescriptionColor`;
|
|
|
|
const tailColorKey: keyof StepsToken = `${status}TailColor`;
|
|
|
|
return {
|
|
|
|
[`${prefix}-${status} ${prefix}-icon`]: {
|
2022-06-28 20:33:01 +08:00
|
|
|
backgroundColor: token.colorBgContainer,
|
2022-04-19 11:28:06 +08:00
|
|
|
borderColor: token[iconColorKey],
|
|
|
|
[`> ${token.componentCls}-icon`]: {
|
|
|
|
color: token[iconColorKey],
|
|
|
|
[`${token.componentCls}-icon-dot`]: {
|
|
|
|
background: token[iconColorKey],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[`${prefix}-${status} > ${prefix}-container > ${prefix}-content > ${prefix}-title`]: {
|
|
|
|
color: token[titleColorKey],
|
|
|
|
|
|
|
|
'&::after': {
|
|
|
|
backgroundColor: token[tailColorKey],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[`${prefix}-${status} > ${prefix}-container > ${prefix}-content > ${prefix}-description`]: {
|
|
|
|
color: token[descriptionColorKey],
|
|
|
|
},
|
|
|
|
[`${prefix}-${status} > ${prefix}-container > ${prefix}-tail::after`]: {
|
|
|
|
backgroundColor: token[tailColorKey],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const genStepsItemStyle: GenerateStyle<StepsToken, CSSObject> = token => {
|
|
|
|
const { componentCls, motionDurationSlow } = token;
|
|
|
|
const stepsItemCls = `${componentCls}-item`; // .ant-steps-item
|
|
|
|
|
|
|
|
return {
|
|
|
|
[stepsItemCls]: {
|
|
|
|
position: 'relative',
|
|
|
|
display: 'inline-block',
|
|
|
|
flex: 1,
|
|
|
|
overflow: 'hidden',
|
|
|
|
verticalAlign: 'top',
|
|
|
|
'&:last-child': {
|
|
|
|
flex: 'none',
|
|
|
|
[`> ${stepsItemCls}-container > ${stepsItemCls}-tail, > ${stepsItemCls}-container > ${stepsItemCls}-content > ${stepsItemCls}-title::after`]:
|
|
|
|
{
|
|
|
|
display: 'none',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[`${stepsItemCls}-container`]: {
|
|
|
|
outline: 'none',
|
|
|
|
},
|
|
|
|
[`${stepsItemCls}-icon, ${stepsItemCls}-content`]: {
|
|
|
|
display: 'inline-block',
|
|
|
|
verticalAlign: 'top',
|
|
|
|
},
|
|
|
|
[`${stepsItemCls}-icon`]: {
|
|
|
|
width: token.stepsIconSize,
|
|
|
|
height: token.stepsIconSize,
|
2022-06-01 11:19:05 +08:00
|
|
|
marginTop: 0,
|
|
|
|
marginBottom: 0,
|
|
|
|
marginInlineStart: 0,
|
|
|
|
marginInlineEnd: token.marginXS,
|
2022-04-19 11:28:06 +08:00
|
|
|
fontSize: token.stepsIconFontSize,
|
|
|
|
fontFamily: token.fontFamily,
|
|
|
|
lineHeight: `${token.stepsIconSize}px`,
|
|
|
|
textAlign: 'center',
|
2022-06-01 11:19:05 +08:00
|
|
|
border: `${token.controlLineWidth}px ${token.controlLineType} ${token.colorTextDisabled}`,
|
2022-04-19 11:28:06 +08:00
|
|
|
borderRadius: token.stepsIconSize,
|
|
|
|
transition: `background-color ${motionDurationSlow}, border-color ${motionDurationSlow}`,
|
|
|
|
[`${componentCls}-icon`]: {
|
|
|
|
position: 'relative',
|
|
|
|
top: token.stepsIconTop,
|
|
|
|
color: token.colorPrimary,
|
|
|
|
lineHeight: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[`${stepsItemCls}-tail`]: {
|
|
|
|
position: 'absolute',
|
2022-06-01 11:19:05 +08:00
|
|
|
top: token.marginSM,
|
|
|
|
insetInlineStart: 0,
|
|
|
|
width: '100%',
|
2022-04-19 11:28:06 +08:00
|
|
|
|
|
|
|
'&::after': {
|
|
|
|
display: 'inline-block',
|
2022-06-01 11:19:05 +08:00
|
|
|
width: '100%',
|
|
|
|
height: token.lineWidth,
|
2022-04-19 11:28:06 +08:00
|
|
|
background: token.colorSplit,
|
2022-06-01 11:19:05 +08:00
|
|
|
borderRadius: token.lineWidth,
|
2022-04-19 11:28:06 +08:00
|
|
|
transition: `background ${motionDurationSlow}`,
|
|
|
|
content: '""',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[`${stepsItemCls}-title`]: {
|
|
|
|
position: 'relative',
|
|
|
|
display: 'inline-block',
|
2022-06-01 11:19:05 +08:00
|
|
|
paddingInlineEnd: token.padding,
|
2022-04-19 11:28:06 +08:00
|
|
|
color: token.colorText,
|
|
|
|
fontSize: token.fontSizeLG,
|
|
|
|
lineHeight: `${token.stepsTitleLineHeight}px`,
|
|
|
|
|
|
|
|
'&::after': {
|
|
|
|
position: 'absolute',
|
|
|
|
top: token.stepsTitleLineHeight / 2,
|
2022-06-01 11:19:05 +08:00
|
|
|
insetInlineStart: '100%',
|
2022-04-19 11:28:06 +08:00
|
|
|
display: 'block',
|
2022-06-01 11:19:05 +08:00
|
|
|
width: 9999,
|
|
|
|
height: token.lineWidth,
|
2022-04-19 11:28:06 +08:00
|
|
|
background: token.processTailColor,
|
|
|
|
content: '""',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[`${stepsItemCls}-subtitle`]: {
|
|
|
|
display: 'inline',
|
2022-06-01 11:19:05 +08:00
|
|
|
marginInlineStart: token.marginXS,
|
2022-04-19 11:28:06 +08:00
|
|
|
color: token.colorTextSecondary,
|
|
|
|
fontWeight: 'normal',
|
|
|
|
fontSize: token.fontSizeBase,
|
|
|
|
},
|
|
|
|
[`${stepsItemCls}-description`]: {
|
|
|
|
color: token.colorTextSecondary,
|
|
|
|
fontSize: token.fontSizeBase,
|
|
|
|
},
|
|
|
|
...genStepsItemStatusStyle(StepItemStatusEnum.wait, token),
|
|
|
|
...genStepsItemStatusStyle(StepItemStatusEnum.process, token),
|
|
|
|
[`${stepsItemCls}-process > ${stepsItemCls}-container > ${stepsItemCls}-icon`]: {
|
|
|
|
background: token.processIconColor,
|
|
|
|
|
|
|
|
[`${componentCls}-icon`]: {
|
|
|
|
color: token.processIconTextColor,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[`${stepsItemCls}-process > ${stepsItemCls}-container > ${stepsItemCls}-title`]: {
|
2022-06-01 11:19:05 +08:00
|
|
|
fontWeight: token.fontWeightStrong,
|
2022-04-19 11:28:06 +08:00
|
|
|
},
|
|
|
|
...genStepsItemStatusStyle(StepItemStatusEnum.finish, token),
|
|
|
|
...genStepsItemStatusStyle(StepItemStatusEnum.error, token),
|
|
|
|
[`${stepsItemCls}${componentCls}-next-error > ${componentCls}-item-title::after`]: {
|
|
|
|
background: token.colorError,
|
|
|
|
},
|
|
|
|
[`${stepsItemCls}-disabled`]: {
|
|
|
|
cursor: 'not-allowed',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// ============================= Clickable ===========================
|
|
|
|
const genStepsClickableStyle: GenerateStyle<StepsToken, CSSObject> = token => {
|
|
|
|
const { componentCls, motionDurationSlow } = token;
|
|
|
|
|
|
|
|
return {
|
|
|
|
[`& ${componentCls}-item`]: {
|
|
|
|
[`&:not(${componentCls}-item-active)`]: {
|
|
|
|
[`& > ${componentCls}-item-container[role='button']`]: {
|
|
|
|
cursor: 'pointer',
|
|
|
|
[`${componentCls}-item`]: {
|
|
|
|
[`&-title, &-subtitle, &-description, &-icon ${componentCls}-icon`]: {
|
|
|
|
transition: `color ${motionDurationSlow}`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'&:hover': {
|
|
|
|
[`${componentCls}-item`]: {
|
|
|
|
[`&-title, &-subtitle, &-description`]: {
|
|
|
|
color: token.colorPrimary,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`&:not(${componentCls}-item-process)`]: {
|
|
|
|
[`& > ${componentCls}-item-container[role='button']:hover`]: {
|
|
|
|
[`${componentCls}-item`]: {
|
|
|
|
'&-icon': {
|
|
|
|
borderColor: token.colorPrimary,
|
|
|
|
|
|
|
|
[`${componentCls}-icon`]: {
|
|
|
|
color: token.colorPrimary,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[`&${componentCls}-horizontal:not(${componentCls}-label-vertical)`]: {
|
|
|
|
[`${componentCls}-item`]: {
|
2022-06-01 11:19:05 +08:00
|
|
|
paddingInlineStart: token.padding,
|
2022-04-19 11:28:06 +08:00
|
|
|
whiteSpace: 'nowrap',
|
|
|
|
|
|
|
|
'&:first-child': {
|
2022-06-01 11:19:05 +08:00
|
|
|
paddingInlineStart: 0,
|
2022-04-19 11:28:06 +08:00
|
|
|
},
|
|
|
|
[`&:last-child ${componentCls}-item-title`]: {
|
2022-06-01 11:19:05 +08:00
|
|
|
paddingInlineEnd: 0,
|
2022-04-19 11:28:06 +08:00
|
|
|
},
|
|
|
|
'&-tail': {
|
|
|
|
display: 'none',
|
|
|
|
},
|
|
|
|
'&-description': {
|
2022-06-01 11:19:05 +08:00
|
|
|
maxWidth: token.descriptionWidth,
|
2022-04-19 11:28:06 +08:00
|
|
|
whiteSpace: 'normal',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const genStepsStyle: GenerateStyle<StepsToken, CSSObject> = token => {
|
|
|
|
const { componentCls } = token; // .ant-steps
|
|
|
|
|
|
|
|
return {
|
|
|
|
[componentCls]: {
|
|
|
|
...resetComponent(token),
|
|
|
|
display: 'flex',
|
|
|
|
width: '100%',
|
2022-06-01 11:19:05 +08:00
|
|
|
fontSize: 0,
|
2022-04-19 11:28:06 +08:00
|
|
|
textAlign: 'initial',
|
|
|
|
// single Item
|
|
|
|
...genStepsItemStyle(token),
|
|
|
|
// Clickable
|
|
|
|
...genStepsClickableStyle(token),
|
|
|
|
// custom-icon
|
|
|
|
...genStepsCustomIconStyle(token),
|
|
|
|
// small
|
|
|
|
...genStepsSmallStyle(token),
|
|
|
|
// vertical
|
|
|
|
...genStepsVerticalStyle(token),
|
|
|
|
// label-placement
|
|
|
|
...genStepsLabelPlacementStyle(token),
|
|
|
|
// progress-dot
|
|
|
|
...genStepsProgressDotStyle(token),
|
|
|
|
// nav
|
|
|
|
...genStepsNavStyle(token),
|
|
|
|
// rtl
|
|
|
|
...genStepsRTLStyle(token),
|
|
|
|
// progress
|
|
|
|
...genStepsProgressStyle(token),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// ============================== Export ==============================
|
2022-06-01 11:19:05 +08:00
|
|
|
export default genComponentStyleHook(
|
|
|
|
'Steps',
|
|
|
|
token => {
|
|
|
|
const stepsIconSize = token.controlHeight;
|
|
|
|
const processTailColor = token.colorSplit;
|
|
|
|
const processIconColor = token.colorPrimary;
|
2022-04-19 11:28:06 +08:00
|
|
|
|
2022-06-01 11:19:05 +08:00
|
|
|
const stepsToken = mergeToken<StepsToken>(token, {
|
|
|
|
// Steps variable default.less
|
|
|
|
processTailColor,
|
|
|
|
stepsNavArrowColor: token.colorTextDisabled,
|
|
|
|
stepsIconSize,
|
|
|
|
stepsIconCustomSize: stepsIconSize,
|
|
|
|
stepsIconCustomTop: 0,
|
|
|
|
stepsIconCustomFontSize: token.fontSizeHeading3,
|
|
|
|
stepsIconTop: -0.5, // magic for ui experience
|
|
|
|
stepsIconFontSize: token.fontSizeLG,
|
|
|
|
stepsTitleLineHeight: token.controlHeight,
|
|
|
|
stepsSmallIconSize: token.fontSizeHeading3,
|
|
|
|
stepsDotSize: token.controlHeight / 4,
|
|
|
|
stepsCurrentDotSize: token.controlHeightLG / 4,
|
|
|
|
stepsNavContentMaxWidth: 'auto',
|
|
|
|
// Steps component less variable
|
|
|
|
processIconColor,
|
|
|
|
processTitleColor: token.colorText,
|
|
|
|
processDescriptionColor: token.colorText,
|
|
|
|
processIconTextColor: token.colorTextLightSolid,
|
|
|
|
waitIconColor: token.colorTextDisabled,
|
|
|
|
waitTitleColor: token.colorTextSecondary,
|
|
|
|
waitDescriptionColor: token.colorTextSecondary,
|
|
|
|
waitTailColor: processTailColor,
|
|
|
|
finishIconColor: processIconColor,
|
|
|
|
finishTitleColor: token.colorText,
|
|
|
|
finishDescriptionColor: token.colorTextSecondary,
|
|
|
|
finishTailColor: token.colorPrimary,
|
|
|
|
errorIconColor: token.colorError,
|
|
|
|
errorTitleColor: token.colorError,
|
|
|
|
errorDescriptionColor: token.colorError,
|
|
|
|
errorTailColor: processTailColor,
|
|
|
|
stepsNavActiveColor: token.colorPrimary,
|
|
|
|
stepsProgressSize: token.controlHeightLG,
|
|
|
|
});
|
2022-04-19 11:28:06 +08:00
|
|
|
|
2022-06-01 11:19:05 +08:00
|
|
|
return [genStepsStyle(stepsToken)];
|
|
|
|
},
|
|
|
|
{
|
|
|
|
descriptionWidth: 140,
|
|
|
|
},
|
|
|
|
);
|