diff --git a/packages/react-form/src/style/item.ts b/packages/react-form/src/style/item.ts index 07b8108ffb..665f60b693 100644 --- a/packages/react-form/src/style/item.ts +++ b/packages/react-form/src/style/item.ts @@ -1,7 +1,7 @@ import styled, { css } from 'styled-components'; import { HTMLInputProps, ThemeVariantValueOptions } from '@uiw/utils'; import { InputStyleBase } from '@uiw/react-input'; -import { SelectWarp } from '@uiw/react-select'; +import { SelectStyleWarp } from '@uiw/react-select'; import { TextareaStyleWarp } from '@uiw/react-textarea'; interface FormStyleItemProps extends HTMLInputProps, ThemeVariantValueOptions { @@ -34,7 +34,7 @@ export const FormStyleItem = styled.div` ${(props) => props.hasError && css` - ${InputStyleBase},${SelectWarp},${TextareaStyleWarp} { + ${InputStyleBase},${SelectStyleWarp},${TextareaStyleWarp} { box-shadow: 0 0 0 1px #dc3545, 0 0 0 3px rgba(220, 53, 69, 0.17), inset 0 1px 1px rgba(16, 22, 26, 0.2); &:hover { box-shadow: 0 0 0 1px #dc3545, 0 0 0 3px rgba(220, 53, 69, 0.17), inset 0 1px 1px rgba(16, 22, 26, 0.2); diff --git a/packages/react-message/README.md b/packages/react-message/README.md index 9f111430f0..6e211a2f5e 100644 --- a/packages/react-message/README.md +++ b/packages/react-message/README.md @@ -83,7 +83,7 @@ export default Demo ```jsx mdx:preview&background=#fff&codeSandbox=true&codePen=true import React from 'react'; -import { Message, Divider } from 'uiw'; +import { Message, Divider ,Icon} from 'uiw'; const chat = ( ); const closed = ; @@ -91,14 +91,14 @@ class Demo extends React.Component { render() { return (
- - - + } type="error" title="自定义图标" description="这里自定义Icon组件图标。" /> + } type="info" title="自定义图标" description="这里自定义 SVG 图标。" /> + } type="success" title="自定义图标" description="这里自定义 SVG 图标。" /> - - - - + } type="success" title="成功提示标题,自定义图标。" /> + } type="warning" title="警告提示标题,自定义图标。" /> + } type="info" title="说明提示标题,自定义图标。" /> + } type="error" title="错误提示标题,自定义图标。" />
) } @@ -143,5 +143,5 @@ export default Demo | rounded | 是否显示圆角 | Boolean | - | | showIcon | 设定显示图标 | Boolean | - | | isCloseButtonShown | 显示关闭按钮 | Boolean | - | -| icon | 自定义图标,设置 `showIcon=true` 才会起作用。 | String/ReactNode | - | +| icon | 自定义图标,设置 `showIcon=true` 才会起作用。 | ReactNode | - | | onClose | 点击默认关闭按钮时触发的回调函数 | Function | - | \ No newline at end of file diff --git a/packages/react-message/src/index.tsx b/packages/react-message/src/index.tsx index 07fc4aa008..d697aff3c7 100644 --- a/packages/react-message/src/index.tsx +++ b/packages/react-message/src/index.tsx @@ -1,13 +1,22 @@ import React from 'react'; import { CSSTransition } from 'react-transition-group'; -import Icon, { IconProps } from '@uiw/react-icon'; +import { IconStyleBase } from '@uiw/react-icon'; // import './style/index.less'; import { IProps, HTMLDivProps } from '@uiw/utils'; - -import { MessageDivWrap, MessageTitleSpan, MessageDescriptionSpan, MessageButtonStyleWarp } from './style'; +import { CircleCheck } from '@uiw/icons/lib/CircleCheck'; +import { Close } from '@uiw/icons/lib/Close'; +import { Warning } from '@uiw/icons/lib/Warning'; +import { Information } from '@uiw/icons/lib/Information'; +import { CircleClose } from '@uiw/icons/lib/CircleClose'; +import { + MessageStyleDivWrap, + MessageStyleTitleSpan, + MessageStyleDescriptionSpan, + MessageStyleButtonWarp, +} from './style'; export interface MessageProps extends IProps, Omit { title?: React.ReactNode; - icon?: IconProps['type']; + icon?: React.ReactNode; type?: 'success' | 'warning' | 'info' | 'error'; description?: React.ReactNode; showIcon?: boolean; @@ -39,26 +48,31 @@ export default class Message extends React.Component { const { type, showIcon } = this.props; - let icon = this.props.icon; - if (!icon && showIcon) { + let base: any = this.props.icon; + if (!base && showIcon) { + let fill; switch (type) { case 'success': - icon = 'circle-check'; + fill = '#28a745'; + base = CircleCheck; break; case 'warning': - icon = 'warning'; + fill = '#ffc107'; + base = Warning; break; case 'info': - icon = 'information'; + fill = '#008ef0'; + base = Information; break; case 'error': - icon = 'circle-close'; + fill = '#dc3545'; + base = CircleClose; break; default: break; } + return ; } - return icon; }; render() { const { @@ -87,18 +101,23 @@ export default class Message extends React.Component + {isCloseButtonShown && ( - } type="light" /> + } + type="light" + /> )} - {showIcon && } - + {showIcon && (icon ? icon : this.renderIcon())} + {title} - - + + {children} - - + + ); if (!isCloseButtonShown) { return Child; diff --git a/packages/react-message/src/style/index.ts b/packages/react-message/src/style/index.ts index 0f984e4d92..b503b066e9 100644 --- a/packages/react-message/src/style/index.ts +++ b/packages/react-message/src/style/index.ts @@ -3,7 +3,7 @@ import { IconStyleBase } from '@uiw/react-icon'; import { getThemeVariantValue, ThemeVariantValueOptions } from '@uiw/utils'; import Button, { ButtonProps } from '@uiw/react-button'; -interface divWrapProps +interface DivWrapProps extends React.DetailedHTMLProps, HTMLDivElement>, ThemeVariantValueOptions { params: { @@ -11,24 +11,23 @@ interface divWrapProps type: 'success' | 'warning' | 'info' | 'error' | undefined; children: any; showIcon: boolean | undefined; - icon: any; title: React.ReactNode; }; } -export const MessageWrap = styled.div` +const MessageStyleWrap = styled.div` padding: 10px 15px; position: relative; font-size: 14px; `; // 最外层div -export const MessageDivWrap = styled(MessageWrap)` +export const MessageStyleDivWrap = styled(MessageStyleWrap)` margin-top: 10px; ${(props) => { if (props.params?.showIcon) { if (props.params?.children && props.params?.title) { return css` - > .w-icon { + > ${IconStyleBase} { font-size: 24px; } `; @@ -120,11 +119,11 @@ interface spanPeops extends React.DetailedHTMLProps` +export const MessageStyleDescriptionSpan = styled(MessageStyleSpanWrap)` color: rgba(0, 0, 0, 0.65); ${(props) => props.params.showIcon && @@ -135,7 +134,7 @@ export const MessageDescriptionSpan = styled(MessageSpanWrap)` `} `; // 标题title -export const MessageTitleSpan = styled(MessageDescriptionSpan)` +export const MessageStyleTitleSpan = styled(MessageStyleDescriptionSpan)` color: rgba(0, 0, 0, 0.85); ${(props) => props.params.showIcon && @@ -146,30 +145,9 @@ export const MessageTitleSpan = styled(MessageDescriptionSpan)` `} `; -interface MessageIconWarpProps extends ThemeVariantValueOptions { - params: { - children: React.ReactNode; - showIcon: boolean | undefined; - title: React.ReactNode; - }; -} -// icon -export const MessageIconWarp = styled.span` - ${(props) => - props.params?.showIcon && - props.params.title && - props.params.children && - css` - font-size: 24px; - `} - top: 14px; - left: 14px; - position: absolute; -`; - interface messageButtonProps extends ButtonProps {} -export const MessageButtonStyleWarp = styled(Button)` +export const MessageStyleButtonWarp = styled(Button)` position: absolute; right: 10px; top: 10px; @@ -185,7 +163,7 @@ export const MessageButtonStyleWarp = styled(Button)` } `; -MessageDivWrap.defaultProps = { +MessageStyleDivWrap.defaultProps = { defaultTheme: { backgroundMessageSuccess: '#afecbd', colorMessageSuccess: '#28a745', diff --git a/packages/react-pagination/src/style/index.ts b/packages/react-pagination/src/style/index.ts index c4d7a5c886..64ad3edf92 100644 --- a/packages/react-pagination/src/style/index.ts +++ b/packages/react-pagination/src/style/index.ts @@ -1,5 +1,5 @@ import styled, { css } from 'styled-components'; -import { SelectWarp } from '@uiw/react-select'; +import { SelectStyleWarp } from '@uiw/react-select'; import { ThemeVariantValueOptions, getThemeVariantValue } from '@uiw/utils'; export const PaginationDefaultTheme = { @@ -186,7 +186,7 @@ export const PaginationStyleBaseLI = styled.li` ${(props) => props.params?.isOptions && css` - ${SelectWarp} { + ${SelectStyleWarp} { border: none !important; padding-top: 0; padding-bottom: 0; diff --git a/packages/react-pin-code/src/index.tsx b/packages/react-pin-code/src/index.tsx index 32a470aba0..e5b7e6d064 100644 --- a/packages/react-pin-code/src/index.tsx +++ b/packages/react-pin-code/src/index.tsx @@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react'; import { IProps, noop } from '@uiw/utils'; import Input, { InputProps } from '@uiw/react-input'; // import './style/input.less'; -import { DivWrap, InputWrap } from './style'; +import { PinCodeStyleDivWrap, PinCodeStyleInputWrap } from './style'; export interface PinCodeProps extends IProps { value?: string[]; @@ -79,7 +79,7 @@ function InternalPinCode(props: PinCodeProps = {}, ref: React.ForwardedRef + {[...values].map((val, key) => { const inpProps: InputProps = { min: 0, @@ -100,7 +100,7 @@ function InternalPinCode(props: PinCodeProps = {}, ref: React.ForwardedRef { if (instance) { input[key] = instance; @@ -112,7 +112,7 @@ function InternalPinCode(props: PinCodeProps = {}, ref: React.ForwardedRef + ); } diff --git a/packages/react-pin-code/src/style/index.ts b/packages/react-pin-code/src/style/index.ts index 0430184199..0beaa804ed 100644 --- a/packages/react-pin-code/src/style/index.ts +++ b/packages/react-pin-code/src/style/index.ts @@ -2,11 +2,11 @@ import styled, { css } from 'styled-components'; import Input, { InputProps, InputStyleBase } from '@uiw/react-input'; // React.DetailedHTMLProps, HTMLDivElement> -export const DivWrap = styled.div` +export const PinCodeStyleDivWrap = styled.div` display: flex; `; -export const InputWrap = styled(Input)` +export const PinCodeStyleInputWrap = styled(Input)` width: 30px; & + & { margin-left: 8px; diff --git a/packages/react-select/src/index.tsx b/packages/react-select/src/index.tsx index d7b4557628..ace0449478 100644 --- a/packages/react-select/src/index.tsx +++ b/packages/react-select/src/index.tsx @@ -4,7 +4,7 @@ import Option from './Option'; import Group from './Group'; // import './style/index.less'; -import { SelectWarp } from './style'; +import { SelectStyleWarp } from './style'; export * from './style'; export interface SelectProps extends IProps, Omit, 'size'> { size?: 'large' | 'default' | 'small'; @@ -14,7 +14,7 @@ const Select = React.forwardRef((props, ref) => const { prefixCls = 'w-select', className, size = 'default', ...other } = props; const cls = [prefixCls, className, size ? `${prefixCls}-${size}` : null].filter(Boolean).join(' ').trim(); - return ; + return ; }); type Select = typeof Select & { diff --git a/packages/react-select/src/style/index.ts b/packages/react-select/src/style/index.ts index 3f49ece957..ca49031169 100644 --- a/packages/react-select/src/style/index.ts +++ b/packages/react-select/src/style/index.ts @@ -11,7 +11,7 @@ interface SelectWarpProps extends ThemeVariantValueOptions, Omit` +export const SelectStyleWarp = styled.select` display: inline-flex; appearance: none; cursor: ${(props) => getThemeVariantValue(props, 'cursorSelectDefault')}; @@ -65,7 +65,7 @@ export const SelectWarp = styled.select` `} `; -SelectWarp.defaultProps = { +SelectStyleWarp.defaultProps = { defaultTheme: { // 大小内边距设置 paddingSelectSmall: '3px 25px 3px 7px',