Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions packages/components/_util/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,6 @@ export function firstUpperCase(str: string): string {
return str.toLowerCase().replace(/( |^)[a-z]/g, (char: string) => char.toUpperCase());
}

export type Gradients = { [percent: string]: string };
export type FromTo = { from: string; to: string };
export type LinearGradient = { direction?: string } & (Gradients | FromTo);
export function getBackgroundColor(color: string | string[] | LinearGradient): string {
if (typeof color === 'string') {
return color;
}
if (Array.isArray(color)) {
if (color[0] && color[0][0] === '#') {
color.unshift('90deg');
}
return `linear-gradient( ${color.join(',')} )`;
}
const { from, to, direction = 'to right', ...rest } = color;
let keys = Object.keys(rest);
if (keys.length) {
keys = keys.sort((a, b) => parseFloat(a.substr(0, a.length - 1)) - parseFloat(b.substr(0, b.length - 1)));
const tempArr = keys.map((key: any) => `${rest[key]} ${key}`);
return `linear-gradient(${direction}, ${tempArr.join(',')})`;
}
return `linear-gradient(${direction}, ${from}, ${to})`;
}

// keyboard-event => onKeyboardEvent
export function getPropsApiByEvent(eventName: string) {
return camelCase(`on-${eventName}`);
Expand Down
23 changes: 0 additions & 23 deletions packages/components/_util/linearGradient.ts

This file was deleted.

24 changes: 14 additions & 10 deletions packages/components/progress/Progress.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import React, { forwardRef } from 'react';
import classNames from 'classnames';
import React, { forwardRef, isValidElement } from 'react';
import {
CloseIcon as TdCloseIcon,
CheckIcon as TdCheckIcon,
ErrorIcon as TdErrorIcon,
CheckCircleFilledIcon as TdCheckCircleFilledIcon,
CheckIcon as TdCheckIcon,
CloseCircleFilledIcon as TdCloseCircleFilledIcon,
CloseIcon as TdCloseIcon,
ErrorCircleFilledIcon as TdErrorCircleFilledIcon,
ErrorIcon as TdErrorIcon,
} from 'tdesign-icons-react';
import classNames from 'classnames';

import { getBackgroundColor } from '@tdesign/common-js/utils/helper';
import useConfig from '../hooks/useConfig';
import useDefaultProps from '../hooks/useDefaultProps';
import useGlobalIcon from '../hooks/useGlobalIcon';
import getBackgroundColor from '../_util/linearGradient';
import { StyledProps } from '../common';
import { TdProgressProps } from './type';
import { progressDefaultProps } from './defaultProps';
import useDefaultProps from '../hooks/useDefaultProps';

import type { StyledProps } from '../common';
import type { TdProgressProps } from './type';

export interface ProgressProps extends TdProgressProps, StyledProps {}
/**
Expand Down Expand Up @@ -217,7 +219,9 @@ const Progress = forwardRef<HTMLDivElement, ProgressProps>((props, ref) => {
{percentage > PLUMP_SEPARATE ? (
<div className={`${classPrefix}-progress__inner`} style={barStyle}>
{label && (
<div className={`${classPrefix}-progress__info`} style={{ color: '#fff' }}>{`${percentage}%`}</div>
<div className={`${classPrefix}-progress__info`} style={{ color: '#fff' }}>
{isValidElement(label) ? label : `${percentage}%`}
</div>
)}
</div>
) : (
Expand Down
Loading