123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.prepareComponentToken = exports.default = exports.Percent = exports.LineStrokeColorVar = void 0;
- var _cssinjs = require("@ant-design/cssinjs");
- var _style = require("../../style");
- var _internal = require("../../theme/internal");
- const LineStrokeColorVar = exports.LineStrokeColorVar = '--progress-line-stroke-color';
- const Percent = exports.Percent = '--progress-percent';
- const genAntProgressActive = isRtl => {
- const direction = isRtl ? '100%' : '-100%';
- return new _cssinjs.Keyframes(`antProgress${isRtl ? 'RTL' : 'LTR'}Active`, {
- '0%': {
- transform: `translateX(${direction}) scaleX(0)`,
- opacity: 0.1
- },
- '20%': {
- transform: `translateX(${direction}) scaleX(0)`,
- opacity: 0.5
- },
- to: {
- transform: 'translateX(0) scaleX(1)',
- opacity: 0
- }
- });
- };
- const genBaseStyle = token => {
- const {
- componentCls: progressCls,
- iconCls: iconPrefixCls
- } = token;
- return {
- [progressCls]: Object.assign(Object.assign({}, (0, _style.resetComponent)(token)), {
- display: 'inline-block',
- '&-rtl': {
- direction: 'rtl'
- },
- '&-line': {
- position: 'relative',
- width: '100%',
- fontSize: token.fontSize
- },
- [`${progressCls}-outer`]: {
- display: 'inline-flex',
- alignItems: 'center',
- width: '100%'
- },
- [`${progressCls}-inner`]: {
- position: 'relative',
- display: 'inline-block',
- width: '100%',
- flex: 1,
- overflow: 'hidden',
- verticalAlign: 'middle',
- backgroundColor: token.remainingColor,
- borderRadius: token.lineBorderRadius
- },
- [`${progressCls}-inner:not(${progressCls}-circle-gradient)`]: {
- [`${progressCls}-circle-path`]: {
- stroke: token.defaultColor
- }
- },
- [`${progressCls}-success-bg, ${progressCls}-bg`]: {
- position: 'relative',
- background: token.defaultColor,
- borderRadius: token.lineBorderRadius,
- transition: `all ${token.motionDurationSlow} ${token.motionEaseInOutCirc}`
- },
- [`${progressCls}-layout-bottom`]: {
- display: 'flex',
- flexDirection: 'column',
- alignItems: 'center',
- justifyContent: 'center',
- [`${progressCls}-text`]: {
- width: 'max-content',
- marginInlineStart: 0,
- marginTop: token.marginXXS
- }
- },
- [`${progressCls}-bg`]: {
- overflow: 'hidden',
- '&::after': {
- content: '""',
- background: {
- _multi_value_: true,
- value: ['inherit', `var(${LineStrokeColorVar})`]
- },
- height: '100%',
- width: `calc(1 / var(${Percent}) * 100%)`,
- display: 'block'
- },
- [`&${progressCls}-bg-inner`]: {
- minWidth: 'max-content',
- '&::after': {
- content: 'none'
- },
- [`${progressCls}-text-inner`]: {
- color: token.colorWhite,
- [`&${progressCls}-text-bright`]: {
- color: 'rgba(0, 0, 0, 0.45)'
- }
- }
- }
- },
- [`${progressCls}-success-bg`]: {
- position: 'absolute',
- insetBlockStart: 0,
- insetInlineStart: 0,
- backgroundColor: token.colorSuccess
- },
- [`${progressCls}-text`]: {
- display: 'inline-block',
- marginInlineStart: token.marginXS,
- color: token.colorText,
- lineHeight: 1,
- width: '2em',
- whiteSpace: 'nowrap',
- textAlign: 'start',
- verticalAlign: 'middle',
- wordBreak: 'normal',
- [iconPrefixCls]: {
- fontSize: token.fontSize
- },
- [`&${progressCls}-text-outer`]: {
- width: 'max-content'
- },
- [`&${progressCls}-text-outer${progressCls}-text-start`]: {
- width: 'max-content',
- marginInlineStart: 0,
- marginInlineEnd: token.marginXS
- }
- },
- [`${progressCls}-text-inner`]: {
- display: 'flex',
- justifyContent: 'center',
- alignItems: 'center',
- width: '100%',
- height: '100%',
- marginInlineStart: 0,
- padding: `0 ${(0, _cssinjs.unit)(token.paddingXXS)}`,
- [`&${progressCls}-text-start`]: {
- justifyContent: 'start'
- },
- [`&${progressCls}-text-end`]: {
- justifyContent: 'end'
- }
- },
- [`&${progressCls}-status-active`]: {
- [`${progressCls}-bg::before`]: {
- position: 'absolute',
- inset: 0,
- backgroundColor: token.colorBgContainer,
- borderRadius: token.lineBorderRadius,
- opacity: 0,
- animationName: genAntProgressActive(),
- animationDuration: token.progressActiveMotionDuration,
- animationTimingFunction: token.motionEaseOutQuint,
- animationIterationCount: 'infinite',
- content: '""'
- }
- },
- [`&${progressCls}-rtl${progressCls}-status-active`]: {
- [`${progressCls}-bg::before`]: {
- animationName: genAntProgressActive(true)
- }
- },
- [`&${progressCls}-status-exception`]: {
- [`${progressCls}-bg`]: {
- backgroundColor: token.colorError
- },
- [`${progressCls}-text`]: {
- color: token.colorError
- }
- },
- [`&${progressCls}-status-exception ${progressCls}-inner:not(${progressCls}-circle-gradient)`]: {
- [`${progressCls}-circle-path`]: {
- stroke: token.colorError
- }
- },
- [`&${progressCls}-status-success`]: {
- [`${progressCls}-bg`]: {
- backgroundColor: token.colorSuccess
- },
- [`${progressCls}-text`]: {
- color: token.colorSuccess
- }
- },
- [`&${progressCls}-status-success ${progressCls}-inner:not(${progressCls}-circle-gradient)`]: {
- [`${progressCls}-circle-path`]: {
- stroke: token.colorSuccess
- }
- }
- })
- };
- };
- const genCircleStyle = token => {
- const {
- componentCls: progressCls,
- iconCls: iconPrefixCls
- } = token;
- return {
- [progressCls]: {
- [`${progressCls}-circle-trail`]: {
- stroke: token.remainingColor
- },
- [`&${progressCls}-circle ${progressCls}-inner`]: {
- position: 'relative',
- lineHeight: 1,
- backgroundColor: 'transparent'
- },
- [`&${progressCls}-circle ${progressCls}-text`]: {
- position: 'absolute',
- insetBlockStart: '50%',
- insetInlineStart: 0,
- width: '100%',
- margin: 0,
- padding: 0,
- color: token.circleTextColor,
- fontSize: token.circleTextFontSize,
- lineHeight: 1,
- whiteSpace: 'normal',
- textAlign: 'center',
- transform: 'translateY(-50%)',
- [iconPrefixCls]: {
- fontSize: token.circleIconFontSize
- }
- },
- [`${progressCls}-circle&-status-exception`]: {
- [`${progressCls}-text`]: {
- color: token.colorError
- }
- },
- [`${progressCls}-circle&-status-success`]: {
- [`${progressCls}-text`]: {
- color: token.colorSuccess
- }
- }
- },
- [`${progressCls}-inline-circle`]: {
- lineHeight: 1,
- [`${progressCls}-inner`]: {
- verticalAlign: 'bottom'
- }
- }
- };
- };
- const genStepStyle = token => {
- const {
- componentCls: progressCls
- } = token;
- return {
- [progressCls]: {
- [`${progressCls}-steps`]: {
- display: 'inline-block',
- '&-outer': {
- display: 'flex',
- flexDirection: 'row',
- alignItems: 'center'
- },
- '&-item': {
- flexShrink: 0,
- minWidth: token.progressStepMinWidth,
- marginInlineEnd: token.progressStepMarginInlineEnd,
- backgroundColor: token.remainingColor,
- transition: `all ${token.motionDurationSlow}`,
- '&-active': {
- backgroundColor: token.defaultColor
- }
- }
- }
- }
- };
- };
- const genSmallLine = token => {
- const {
- componentCls: progressCls,
- iconCls: iconPrefixCls
- } = token;
- return {
- [progressCls]: {
- [`${progressCls}-small&-line, ${progressCls}-small&-line ${progressCls}-text ${iconPrefixCls}`]: {
- fontSize: token.fontSizeSM
- }
- }
- };
- };
- const prepareComponentToken = token => ({
- circleTextColor: token.colorText,
- defaultColor: token.colorInfo,
- remainingColor: token.colorFillSecondary,
- lineBorderRadius: 100,
- // magic for capsule shape, should be a very large number
- circleTextFontSize: '1em',
- circleIconFontSize: `${token.fontSize / token.fontSizeSM}em`
- });
- exports.prepareComponentToken = prepareComponentToken;
- var _default = exports.default = (0, _internal.genStyleHooks)('Progress', token => {
- const progressStepMarginInlineEnd = token.calc(token.marginXXS).div(2).equal();
- const progressToken = (0, _internal.mergeToken)(token, {
- progressStepMarginInlineEnd,
- progressStepMinWidth: progressStepMarginInlineEnd,
- progressActiveMotionDuration: '2.4s'
- });
- return [genBaseStyle(progressToken), genCircleStyle(progressToken), genStepStyle(progressToken), genSmallLine(progressToken)];
- }, prepareComponentToken);
|