diff --git a/packages/react-pin-code/src/index.tsx b/packages/react-pin-code/src/index.tsx index 442f6c8db6..32a470aba0 100644 --- a/packages/react-pin-code/src/index.tsx +++ b/packages/react-pin-code/src/index.tsx @@ -1,7 +1,8 @@ import React, { useEffect, useState } from 'react'; import { IProps, noop } from '@uiw/utils'; import Input, { InputProps } from '@uiw/react-input'; -import './style/input.less'; +// import './style/input.less'; +import { DivWrap, InputWrap } from './style'; export interface PinCodeProps extends IProps { value?: string[]; @@ -78,7 +79,7 @@ function InternalPinCode(props: PinCodeProps = {}, ref: React.ForwardedRef + {[...values].map((val, key) => { const inpProps: InputProps = { min: 0, @@ -99,7 +100,7 @@ function InternalPinCode(props: PinCodeProps = {}, ref: React.ForwardedRef { if (instance) { input[key] = instance; @@ -111,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 new file mode 100644 index 0000000000..be3babb26b --- /dev/null +++ b/packages/react-pin-code/src/style/index.ts @@ -0,0 +1,38 @@ +import styled, { css } from 'styled-components'; +import Input, { InputProps, InputBase } from '@uiw/react-input'; + +// React.DetailedHTMLProps, HTMLDivElement> +export const DivWrap = styled.div` + display: flex; +`; + +export const InputWrap = styled(Input)` + width: 30px; + & + & { + margin-left: 8px; + } + > ${InputBase} { + text-align: center; + padding: 0 !important; + font-size: 14px; + font-weight: bold; + } + + ${(props) => + props?.size === 'large' && + css` + width: 36px; + ${InputBase} { + font-size: 16px; + } + `} + + ${(props) => + props?.size === 'small' && + css` + width: 24px; + ${InputBase} { + font-size: 12px; + } + `} +`;