Skip to content

Commit 1f6263e

Browse files
update styles Input/OTP
1 parent 528209d commit 1f6263e

File tree

5 files changed

+13
-17
lines changed

5 files changed

+13
-17
lines changed

ForDevelopers.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ If we update **Storybook configs**, it won't impact projects that install the li
6161
If the changes are **only for developers**, there's **no need to bump the version**!
6262

6363
## Core Component Principles
64-
64+
- **Use this reccomendations https://www.w3.org/WAI/ARIA/apg/patterns/**
6565
- **Extensibility and Flexibility**: Follow the **Open-Closed Principle** from SOLID — components should be open for extension but closed for modification.
6666
- **Style Overriding**:
6767
- An external `className` should **override** the component’s internal styles.

src/lib/common/Input/Input/Input.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export type TInputProps = {
1313
className?: string
1414
classNameWrap?: string
1515
size?: TInputSize
16-
maxWidth?: boolean
1716
icon?: React.ReactNode
1817
iconHint?: React.ReactNode
1918
placeholder?: string

src/lib/common/Input/OTP/OTP.module.pcss

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.otp_container {
22
display: flex;
3+
flex-direction: row;
34
gap: 8px;
45
& > div {
56
width: min-content;

src/lib/common/Input/OTP/OTP.stories.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,16 @@ export const Primary: Story = {
5757
},
5858
}
5959
export const PrimaryFull: Story = {
60+
args: {
61+
numInputs: 6,
62+
},
63+
6064
render: args => {
6165
const [{ otp, numInputs, placeholder, inputType }, setConfig] = useState({
6266
otp: '',
63-
numInputs: 5,
67+
numInputs: 6,
6468
separator: '-',
65-
placeholder: '-----',
69+
placeholder: '------',
6670
inputType: 'number' as const,
6771
})
6872

src/lib/common/Input/OTP/OTP.tsx

+5-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import cls from './OTP.module.pcss'
2-
import React, { ComponentProps, ReactNode, useCallback, useEffect, useRef } from 'react'
2+
import React, { ReactNode, useCallback, useEffect, useRef } from 'react'
33
import { Input, TInputSize } from '../Input/Input'
44
import { MetaInput } from '../MetaInput/MetaInput'
55

@@ -19,29 +19,17 @@ export type TOTPProps = {
1919
placeholder?: string
2020
/** Function to render the separator */
2121
renderSeparator?: ((index: number) => React.ReactNode) | React.ReactNode
22-
/** Style for the container */
23-
containerStyle?: React.CSSProperties | string
2422
/** The type that will be passed to the input being rendered */
2523
inputType?: TAllowedInputTypes
26-
/** Do not apply the default styles to the inputs, will be removed in future versions */
27-
skipDefaultStyles?: boolean // TODO: Remove in next major release
2824
isError?: boolean
29-
className?: string
3025
classNameWrap?: string
3126
size?: TInputSize
32-
maxWidth?: boolean
33-
icon?: React.ReactNode
3427
iconHint?: React.ReactNode
3528
labelText?: string
3629
subLabelText?: string
3730
hintText?: string | ReactNode
38-
id?: string
3931
isDisabled?: boolean
40-
isHovered?: boolean
41-
isPressed?: boolean
42-
isFocused?: boolean
4332
isSuccess?: boolean
44-
onClick?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void
4533
}
4634

4735
/**This solution is taken from [https://github.com/devfolioco/react-otp-input/blob/main/example/src/App.tsx].
@@ -54,6 +42,8 @@ export type TOTPProps = {
5442
4. Add Ctrl+Z for undoing the last insertion.
5543
*/
5644
export const OTP = ({
45+
isDisabled,
46+
size,
5747
value = '',
5848
numInputs = 4,
5949
onChange,
@@ -221,6 +211,7 @@ export const OTP = ({
221211
{Array.from({ length: numInputs }, (_, index) => index).map(index => (
222212
<React.Fragment key={index}>
223213
<Input
214+
isDisabled={isDisabled}
224215
value={getOTPValue()[index] ?? ''}
225216
placeholder={getPlaceholderValue()?.[index] ?? undefined}
226217
ref={element => (inputRefs.current[index] = element)}
@@ -237,6 +228,7 @@ export const OTP = ({
237228
isPressed={activeInput === index}
238229
isError={isError}
239230
className={cls.otp_input}
231+
size={size}
240232
/>
241233
{index < numInputs - 1 &&
242234
(typeof renderSeparator === 'function' ? renderSeparator(index) : renderSeparator)}

0 commit comments

Comments
 (0)