mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 13:09:40 +08:00
4ca2ed63bd
* feat: V5 Responsive Circle Progress * fix: add useMemo * Update components/progress/demo/circle-micro.md Co-authored-by: MadCcc <1075746765@qq.com> * Update components/progress/demo/circle-micro.md Co-authored-by: MadCcc <1075746765@qq.com> * Update components/progress/demo/circle-micro.md Co-authored-by: MadCcc <1075746765@qq.com> * Update components/progress/progress.tsx Co-authored-by: MadCcc <1075746765@qq.com> * fix: raname processInfo * fix: add dep list * fix: add demo * fix: fix width * fix: fix width * fix: fix snap * fix: rename * fix: snap * Update components/progress/Circle.tsx Co-authored-by: MadCcc <1075746765@qq.com> * fix: rename * fix: fix style * fix: update demo * fix: fix style * fix: fix ci * fix: fix style * fix: del verticalAlign * fix: fix * fix: fix cicd * fix: update demo * fix: update demo * fix: fix style * fix: fix style Co-authored-by: MadCcc <1075746765@qq.com>
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { presetPrimaryColors } from '@ant-design/colors';
|
|
import type { CircleProps } from './Circle';
|
|
import type { ProgressProps } from './progress';
|
|
import warning from '../_util/warning';
|
|
|
|
export function validProgress(progress?: number) {
|
|
if (!progress || progress < 0) {
|
|
return 0;
|
|
}
|
|
if (progress > 100) {
|
|
return 100;
|
|
}
|
|
return progress;
|
|
}
|
|
|
|
export function getSuccessPercent({ success, successPercent }: ProgressProps) {
|
|
let percent = successPercent;
|
|
/** @deprecated Use `percent` instead */
|
|
if (success && 'progress' in success) {
|
|
warning(
|
|
false,
|
|
'Progress',
|
|
'`success.progress` is deprecated. Please use `success.percent` instead.',
|
|
);
|
|
percent = success.progress;
|
|
}
|
|
if (success && 'percent' in success) {
|
|
percent = success.percent;
|
|
}
|
|
return percent;
|
|
}
|
|
|
|
export const getPercentage = ({ percent, success, successPercent }: ProgressProps) => {
|
|
const realSuccessPercent = validProgress(getSuccessPercent({ success, successPercent }));
|
|
return [realSuccessPercent, validProgress(validProgress(percent) - realSuccessPercent)];
|
|
};
|
|
|
|
export const getStrokeColor = ({
|
|
success = {},
|
|
strokeColor,
|
|
}: Partial<CircleProps>): (string | Record<PropertyKey, string>)[] => {
|
|
const { strokeColor: successColor } = success;
|
|
return [successColor || presetPrimaryColors.green, strokeColor || null!];
|
|
};
|