123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304 |
- import { unit } from '@ant-design/cssinjs';
- import { genFocusOutline, resetComponent } from '../../style';
- import { genStyleHooks, mergeToken } from '../../theme/internal';
- import genStepsCustomIconStyle from './custom-icon';
- import genStepsHorizontalStyle from './horizontal';
- import genStepsInlineStyle from './inline';
- import genStepsLabelPlacementStyle from './label-placement';
- import genStepsNavStyle from './nav';
- import genStepsProgressStyle from './progress';
- import genStepsProgressDotStyle from './progress-dot';
- import genStepsRTLStyle from './rtl';
- import genStepsSmallStyle from './small';
- import genStepsVerticalStyle from './vertical';
- const STEP_ITEM_STATUS_WAIT = 'wait';
- const STEP_ITEM_STATUS_PROCESS = 'process';
- const STEP_ITEM_STATUS_FINISH = 'finish';
- const STEP_ITEM_STATUS_ERROR = 'error';
- const genStepsItemStatusStyle = (status, token) => {
- const prefix = `${token.componentCls}-item`;
- const iconColorKey = `${status}IconColor`;
- const titleColorKey = `${status}TitleColor`;
- const descriptionColorKey = `${status}DescriptionColor`;
- const tailColorKey = `${status}TailColor`;
- const iconBgColorKey = `${status}IconBgColor`;
- const iconBorderColorKey = `${status}IconBorderColor`;
- const dotColorKey = `${status}DotColor`;
- return {
- [`${prefix}-${status} ${prefix}-icon`]: {
- backgroundColor: token[iconBgColorKey],
- borderColor: token[iconBorderColorKey],
- [`> ${token.componentCls}-icon`]: {
- color: token[iconColorKey],
- [`${token.componentCls}-icon-dot`]: {
- background: token[dotColorKey]
- }
- }
- },
- [`${prefix}-${status}${prefix}-custom ${prefix}-icon`]: {
- [`> ${token.componentCls}-icon`]: {
- color: token[dotColorKey]
- }
- },
- [`${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 = token => {
- const {
- componentCls,
- motionDurationSlow
- } = token;
- const stepsItemCls = `${componentCls}-item`; // .ant-steps-item
- const stepItemIconCls = `${stepsItemCls}-icon`;
- return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({
- [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',
- [`&:focus-visible ${stepItemIconCls}`]: genFocusOutline(token)
- },
- [`${stepItemIconCls}, ${stepsItemCls}-content`]: {
- display: 'inline-block',
- verticalAlign: 'top'
- },
- [stepItemIconCls]: {
- width: token.iconSize,
- height: token.iconSize,
- marginTop: 0,
- marginBottom: 0,
- marginInlineStart: 0,
- marginInlineEnd: token.marginXS,
- fontSize: token.iconFontSize,
- fontFamily: token.fontFamily,
- lineHeight: unit(token.iconSize),
- textAlign: 'center',
- borderRadius: token.iconSize,
- border: `${unit(token.lineWidth)} ${token.lineType} transparent`,
- transition: `background-color ${motionDurationSlow}, border-color ${motionDurationSlow}`,
- [`${componentCls}-icon`]: {
- position: 'relative',
- top: token.iconTop,
- color: token.colorPrimary,
- lineHeight: 1
- }
- },
- [`${stepsItemCls}-tail`]: {
- position: 'absolute',
- top: token.calc(token.iconSize).div(2).equal(),
- insetInlineStart: 0,
- width: '100%',
- '&::after': {
- display: 'inline-block',
- width: '100%',
- height: token.lineWidth,
- background: token.colorSplit,
- borderRadius: token.lineWidth,
- transition: `background ${motionDurationSlow}`,
- content: '""'
- }
- },
- [`${stepsItemCls}-title`]: {
- position: 'relative',
- display: 'inline-block',
- paddingInlineEnd: token.padding,
- color: token.colorText,
- fontSize: token.fontSizeLG,
- lineHeight: unit(token.titleLineHeight),
- '&::after': {
- position: 'absolute',
- top: token.calc(token.titleLineHeight).div(2).equal(),
- insetInlineStart: '100%',
- display: 'block',
- width: 9999,
- height: token.lineWidth,
- background: token.processTailColor,
- content: '""'
- }
- },
- [`${stepsItemCls}-subtitle`]: {
- display: 'inline',
- marginInlineStart: token.marginXS,
- color: token.colorTextDescription,
- fontWeight: 'normal',
- fontSize: token.fontSize
- },
- [`${stepsItemCls}-description`]: {
- color: token.colorTextDescription,
- fontSize: token.fontSize
- }
- }, genStepsItemStatusStyle(STEP_ITEM_STATUS_WAIT, token)), genStepsItemStatusStyle(STEP_ITEM_STATUS_PROCESS, token)), {
- [`${stepsItemCls}-process > ${stepsItemCls}-container > ${stepsItemCls}-title`]: {
- fontWeight: token.fontWeightStrong
- }
- }), genStepsItemStatusStyle(STEP_ITEM_STATUS_FINISH, token)), genStepsItemStatusStyle(STEP_ITEM_STATUS_ERROR, token)), {
- [`${stepsItemCls}${componentCls}-next-error > ${componentCls}-item-title::after`]: {
- background: token.colorError
- },
- [`${stepsItemCls}-disabled`]: {
- cursor: 'not-allowed'
- }
- });
- };
- // ============================= Clickable ===========================
- const genStepsClickableStyle = 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`]: {
- paddingInlineStart: token.padding,
- whiteSpace: 'nowrap',
- '&:first-child': {
- paddingInlineStart: 0
- },
- [`&:last-child ${componentCls}-item-title`]: {
- paddingInlineEnd: 0
- },
- '&-tail': {
- display: 'none'
- },
- '&-description': {
- maxWidth: token.descriptionMaxWidth,
- whiteSpace: 'normal'
- }
- }
- }
- };
- };
- const genStepsStyle = token => {
- const {
- componentCls
- } = token; // .ant-steps
- return {
- [componentCls]: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, resetComponent(token)), {
- display: 'flex',
- width: '100%',
- fontSize: 0,
- textAlign: 'initial'
- }), genStepsItemStyle(token)), genStepsClickableStyle(token)), genStepsCustomIconStyle(token)), genStepsSmallStyle(token)), genStepsVerticalStyle(token)), genStepsHorizontalStyle(token)), genStepsLabelPlacementStyle(token)), genStepsProgressDotStyle(token)), genStepsNavStyle(token)), genStepsRTLStyle(token)), genStepsProgressStyle(token)), genStepsInlineStyle(token))
- };
- };
- // ============================== Export ==============================
- export const prepareComponentToken = token => ({
- titleLineHeight: token.controlHeight,
- customIconSize: token.controlHeight,
- customIconTop: 0,
- customIconFontSize: token.controlHeightSM,
- iconSize: token.controlHeight,
- iconTop: -0.5,
- // magic for ui experience
- iconFontSize: token.fontSize,
- iconSizeSM: token.fontSizeHeading3,
- dotSize: token.controlHeight / 4,
- dotCurrentSize: token.controlHeightLG / 4,
- navArrowColor: token.colorTextDisabled,
- navContentMaxWidth: 'unset',
- descriptionMaxWidth: 140,
- waitIconColor: token.wireframe ? token.colorTextDisabled : token.colorTextLabel,
- waitIconBgColor: token.wireframe ? token.colorBgContainer : token.colorFillContent,
- waitIconBorderColor: token.wireframe ? token.colorTextDisabled : 'transparent',
- finishIconBgColor: token.wireframe ? token.colorBgContainer : token.controlItemBgActive,
- finishIconBorderColor: token.wireframe ? token.colorPrimary : token.controlItemBgActive
- });
- export default genStyleHooks('Steps', token => {
- const {
- colorTextDisabled,
- controlHeightLG,
- colorTextLightSolid,
- colorText,
- colorPrimary,
- colorTextDescription,
- colorTextQuaternary,
- colorError,
- colorBorderSecondary,
- colorSplit
- } = token;
- const stepsToken = mergeToken(token, {
- // Steps component less variable
- processIconColor: colorTextLightSolid,
- processTitleColor: colorText,
- processDescriptionColor: colorText,
- processIconBgColor: colorPrimary,
- processIconBorderColor: colorPrimary,
- processDotColor: colorPrimary,
- processTailColor: colorSplit,
- waitTitleColor: colorTextDescription,
- waitDescriptionColor: colorTextDescription,
- waitTailColor: colorSplit,
- waitDotColor: colorTextDisabled,
- finishIconColor: colorPrimary,
- finishTitleColor: colorText,
- finishDescriptionColor: colorTextDescription,
- finishTailColor: colorPrimary,
- finishDotColor: colorPrimary,
- errorIconColor: colorTextLightSolid,
- errorTitleColor: colorError,
- errorDescriptionColor: colorError,
- errorTailColor: colorSplit,
- errorIconBgColor: colorError,
- errorIconBorderColor: colorError,
- errorDotColor: colorError,
- stepsNavActiveColor: colorPrimary,
- stepsProgressSize: controlHeightLG,
- // Steps inline variable
- inlineDotSize: 6,
- inlineTitleColor: colorTextQuaternary,
- inlineTailColor: colorBorderSecondary
- });
- return genStepsStyle(stepsToken);
- }, prepareComponentToken);
|