ant-design/components/steps/style/progress.ts
二货爱吃白萝卜 8db39e34a7
feat: ConfigProvider support classNames and styles for Steps (#53789)
* basic flex

* chore: style basic

* chore: status style

* chore: small size

* chore: label vertical

* chore: more style

* chore: hover disabled

* chore: variant

* chore: dot variant

* chore: max width

* chore: hover dot

* chore: update style

* chore: click style

* chore: init percent

* chore: pass detail

* chore: for progress

* chore: clean up

* chore: clean up

* chore: multiple css var

* chore: status text

* chore: status use var

* chore: fix nest

* chore: use svg

* chore: type of panel

* chore: offset support

* chore: inline offset

* chore: warning of steps

* docs: add semantic preview

* chore: semantic transition

* chore: hover

* chore: adjust style

* chore: update semantic preview

* chore: fix nav style

* chore: patch panel motion

* chore: update semantic preview

* docs: update config provider doc

* chore: fix part ts def

* chore: fix test ts

* test: update test case

* test: coverage

* chore: fix lint

* test: update test case

* test: update snapshot

* chore: adjust style

* chore: fix rtl

* docs: update design

* chore: update sctructure

* chore: update comment

* chore: clean up

* chore: clean up

* chore: cursor style

* chore: coverage

* docs: add missing part

* chore: order

* test: add test case

* chore: fix ts

* chore: clean up
2025-05-13 20:36:54 +08:00

107 lines
3.1 KiB
TypeScript

import type { CSSObject } from '@ant-design/cssinjs';
import { unit } from '@ant-design/cssinjs';
import type { StepsToken } from '.';
import type { GenerateStyle } from '../../theme/internal';
const genStepsProgressStyle: GenerateStyle<StepsToken, CSSObject> = (token) => {
const { calc, antCls, componentCls, iconSize, iconSizeSM, lineWidthBold, paddingXXS } = token;
const itemCls = `${componentCls}-item`;
const progressSize = token.calc(iconSize).add(token.calc(lineWidthBold).mul(4).equal()).equal();
const progressSizeSM = token
.calc(iconSizeSM)
.add(token.calc(token.lineWidth).mul(4).equal())
.equal();
const enhanceSize = calc(lineWidthBold).add(lineWidthBold).equal();
return {
[`${componentCls}${componentCls}-with-progress`]: {
'--steps-item-wrapper-padding-top': enhanceSize,
[`${itemCls}${itemCls}-process`]: {
[`${itemCls}-icon`]: {
position: 'relative',
},
},
[`${itemCls}-progress-icon`]: {
'&-svg': {
'--steps-svg-size': calc(enhanceSize).mul(2).add(`var(--steps-icon-size)`).equal(),
'--icon-size-ptg-unitless': `calc(100 / tan(atan2(var(--steps-svg-size),1px)))`,
fontSize: `var(--steps-svg-size)`,
lineHeight: `var(--icon-size-ptg-unitless)`,
position: 'absolute',
inset: calc(enhanceSize).mul(-1).equal(),
width: 'auto',
height: 'auto',
},
'&-circle': {
lineHeight: `var(--icon-size-ptg-unitless)`,
strokeWidth: calc(`var(--icon-size-ptg-unitless)`).mul(lineWidthBold).equal(),
'--progress-r': calc(`var(--steps-svg-size)`)
.sub(lineWidthBold)
.mul(`var(--icon-size-ptg-unitless)`)
.div(2)
.equal(),
r: `var(--progress-r)`,
fill: 'none',
cx: 50,
cy: 50,
transition: `all ${token.motionDurationSlow} ease-in-out`,
'&-rail': {
stroke: token.colorSplit,
},
'&-ptg': {
stroke: token.colorPrimary,
},
},
},
},
[`&${componentCls}-with-progress11`]: {
// ==========================================================
// == Shared ==
// ==========================================================
[itemCls]: {
paddingTop: paddingXXS,
paddingInlineStart: paddingXXS,
},
[`${itemCls}-icon`]: {
position: 'relative',
[`${antCls}-progress`]: {
position: 'absolute',
left: {
_skip_check_: true,
value: '50%',
},
top: '50%',
transform: 'translate(-50%, -50%)',
'&-body': {
width: `${unit(progressSize)} !important`,
height: `${unit(progressSize)} !important`,
},
},
},
[`&${componentCls}-small`]: {
[`${itemCls}-icon ${antCls}-progress-body`]: {
width: `${unit(progressSizeSM)} !important`,
height: `${unit(progressSizeSM)} !important`,
},
},
},
};
};
export default genStepsProgressStyle;