Skip to content

Commit

Permalink
fix: optimized code volume
Browse files Browse the repository at this point in the history
  • Loading branch information
LonelySnowman committed May 9, 2024
1 parent e4da3e1 commit 33f84f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
10 changes: 5 additions & 5 deletions components/progress/progress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ const Progress = React.forwardRef<HTMLDivElement, ProgressProps>((props, ref) =>
const prefixCls = getPrefixCls('progress', customizePrefixCls);
const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);

const isLineType = type === 'line';
const isPureLineType = isLineType && !steps;
const progressInfo = React.useMemo<React.ReactNode>(() => {
if (!showInfo) {
return null;
}
const successPercent = getSuccessPercent(props);
let text: React.ReactNode;
const textFormatter = format || ((number) => `${number}%`);
const isLineType = type === 'line';
const isPureLineType = isLineType && !steps;
const isBrightInnerColor = isLineType && strokeColorIsBright && infoPosition === 'inner';
if (
infoPosition === 'inner' ||
Expand Down Expand Up @@ -220,9 +220,9 @@ const Progress = React.forwardRef<HTMLDivElement, ProgressProps>((props, ref) =>
{
[`${prefixCls}-${(type === 'dashboard' && 'circle') || type}`]: type !== 'line',
[`${prefixCls}-inline-circle`]: type === 'circle' && getSize(size, 'circle')[0] <= 20,
[`${prefixCls}-line`]: !steps && type === 'line',
[`${prefixCls}-line-align-${infoAlign}`]: !steps && type === 'line',
[`${prefixCls}-line-position-${infoPosition}`]: !steps && type === 'line',
[`${prefixCls}-line`]: isPureLineType,
[`${prefixCls}-line-align-${infoAlign}`]: isPureLineType,
[`${prefixCls}-line-position-${infoPosition}`]: isPureLineType,
[`${prefixCls}-steps`]: steps,
[`${prefixCls}-show-info`]: showInfo,
[`${prefixCls}-${size}`]: typeof size === 'string',
Expand Down
25 changes: 8 additions & 17 deletions components/progress/style/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ const genBaseStyle: GenerateStyle<ProgressToken> = (token) => {
},
[`&${progressCls}-bg-inner`]: {
minWidth: 'max-content',
[`${progressCls}-text-inner`]: {
color: token.colorWhite,
position: 'relative',
zIndex: 1,
[`&${progressCls}-text-bright`]: {
color: 'rgba(0, 0, 0, 0.45)',
},
},
},
},

Expand Down Expand Up @@ -173,15 +181,6 @@ const genBaseStyle: GenerateStyle<ProgressToken> = (token) => {
marginInlineStart: 0,
marginInlineEnd: token.marginXS,
},
[`&${progressCls}-text-inner`]: {
color: token.colorWhite,
width: '100%',
position: 'relative',
zIndex: 1,
[`&${progressCls}-text-bright`]: {
color: 'rgba(0, 0, 0, 0.45)',
},
},
},

[`${progressCls}-text-inner`]: {
Expand Down Expand Up @@ -243,14 +242,6 @@ const genBaseStyle: GenerateStyle<ProgressToken> = (token) => {
},
[`${progressCls}-text`]: {
color: token.colorSuccess,
[`&${progressCls}-text-inner`]: {
color: token.colorWhite,
position: 'relative',
zIndex: 1,
[`&${progressCls}-text-bright`]: {
color: 'rgba(0, 0, 0, 0.45)',
},
},
},
},

Expand Down

0 comments on commit 33f84f4

Please sign in to comment.