From 511eb8ef5bc1c1453fc8531145f7b1f08a3cea51 Mon Sep 17 00:00:00 2001 From: SunLxy <1011771396@qq.com> Date: Sat, 28 May 2022 15:31:09 +0800 Subject: [PATCH] =?UTF-8?q?refactor(steps):=E6=8A=BD=E7=A6=BBicon=E5=9B=BE?= =?UTF-8?q?=E6=A0=87(#826)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/react-steps/README.md | 7 ++++--- packages/react-steps/src/Step.tsx | 28 ++++++++++--------------- packages/react-steps/src/index.ts | 2 +- packages/react-steps/src/style/index.ts | 11 ++++++++++ 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/packages/react-steps/README.md b/packages/react-steps/README.md index a0134ba2ab..caa77f1f84 100644 --- a/packages/react-steps/README.md +++ b/packages/react-steps/README.md @@ -21,7 +21,6 @@ import Steps from '@uiw/react-steps'; ```jsx mdx:preview import React from 'react'; import { Steps } from 'uiw'; - function Demo() { return ( @@ -66,13 +65,15 @@ export default Demo ```jsx mdx:preview import React from 'react'; import { Steps, Icon } from 'uiw'; +import { StepsItemHeadInnerSvg } from 'uiw'; +import { Message } from "@uiw/icons" function Demo() { return ( } title="注册" description="这里是步骤一的说明,可以很长很长哦。" /> } title="上传头像" description="这里是步骤一的说明,可以很长很长哦。" /> - + } title="验证邮箱" description="这里是步骤一的说明,可以很长很长哦。" /> ) } @@ -230,4 +231,4 @@ export default Demo | status | 指定状态。当不配置该属性时,会使用 Steps 的 current 来自动指定状态。可选:`wait` `process` `finish` `error` | String | `wait` | | title | 指定每个步骤标题 | String/ReactNode | - | | description | 步骤的详情描述,可选 | String/ReactNode | - | -| icon | 步骤的图标,字符串类型从``组件中找,可选 | String/ReactNode | - | +| icon | 步骤的图标,字符串类型从``组件中找,可选 | ReactNode | - | diff --git a/packages/react-steps/src/Step.tsx b/packages/react-steps/src/Step.tsx index 467f1e7146..f29d7a4bad 100644 --- a/packages/react-steps/src/Step.tsx +++ b/packages/react-steps/src/Step.tsx @@ -1,6 +1,9 @@ import React, { CSSProperties } from 'react'; import Icon, { IconProps, IconsName } from '@uiw/react-icon'; import { IProps, HTMLDivProps } from '@uiw/utils'; +import { Check } from '@uiw/icons/lib/Check'; +import { Close } from '@uiw/icons/lib/Close'; + // import './style/index.less'; import { StepsItem, @@ -13,8 +16,8 @@ import { StepsItemMainDescription, StepsItemHeadInnerDot, StepsItemHeadInnerIcon, + StepsItemHeadInnerSvg, } from './style'; - export interface StepProps extends IProps, Omit { nextError?: boolean | undefined; title?: React.ReactNode; @@ -24,7 +27,7 @@ export interface StepProps extends IProps, Omit { itemWidth?: number; stepNumber?: string; adjustMarginRight?: number; - icon?: IconProps['type']; + icon?: React.ReactNode; direction?: 'horizontal' | 'vertical'; } @@ -73,23 +76,14 @@ export default function Step(props: StepProps) { {icon} ); - } else if ((icon && typeof icon === 'string') || status === 'finish' || status === 'error') { + } else if (status === 'finish' || status === 'error') { + iconNode = ; + } else { iconNode = ( - + + {stepNumber} + ); - } else { - iconNode = {stepNumber}; } return ( ` `; StepsItemHeadInnerIcon.defaultProps = { defaultTheme: StepsBaseDefaultTheme }; +export const StepsItemHeadInnerSvg = styled.svg` + fill: currentcolor; + height: 1em; + width: 1em; + display: inline-flex; + align-self: center; + position: relative; + transition: color 0.3s; + box-sizing: inherit; +`; + export interface StepsItemMainProps extends StepsBaseProps { params?: { dot?: boolean;