Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[370] [CodeInput, InputField and TextArea] Replace errorMsg with error #371

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
12 changes: 5 additions & 7 deletions src/components/CodeInput/CodeInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ThemeMode } from '../../types';
import { getThemedColor } from '../../utils/colorUtils';
import Typography, { TypographySize } from '../Typography';

import { CodeInputProps, CodeInputType } from './CodeInput.constants';
import { CodeInputProps, CodeInputType } from './CodeInput.types';
import { isValid, padEnd } from './CodeInput.utils';

const CodeInputContainer = styled.div`
Expand Down Expand Up @@ -60,7 +60,7 @@ const CodeInputField = styled.input<{
const CodeInput: React.FC<CodeInputProps> = ({
codeLength,
dataTest,
errorMsg,
error,
isSubmitting,
value,
onChange,
Expand Down Expand Up @@ -163,18 +163,16 @@ const CodeInput: React.FC<CodeInputProps> = ({
disabled={isSubmitting}
$active={index === focusedFieldIndex}
$codeLength={codeLength}
$error={!!errorMsg}
$error={!!error}
$forceTheme={forceTheme}
$type={type}
/>
))}
</CodeInputContainer>
{errorMsg && (
<div style={{ minHeight: 4 }}>
{!!error && typeof error === 'string' && (
<Typography forceTheme={forceTheme} color='destructive' size={TypographySize.SMALL} wrap>
{errorMsg}
{error}
</Typography>
</div>
)}
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ export type CodeInputProps = {
onSubmit: () => Promise<void> | void;
/** Indicator for e2e tests */
dataTest?: string;
/**
* Submit error message
* Undefined indicates that there is no error
*/
errorMsg?: string;
/** Error state / message */
error?: boolean | string;
/** Forced theme mode */
forceTheme?: ThemeMode;
/** Controlled loading value */
Expand Down
2 changes: 1 addition & 1 deletion src/components/CodeInput/CodeInput.utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CodeInputType } from './CodeInput.constants';
import { CodeInputType } from './CodeInput.types';

/** Checks that the input is valid
* @param {CodeInputType} type - The input type
Expand Down
2 changes: 1 addition & 1 deletion src/components/CodeInput/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default } from './CodeInput';
export { CodeInputType } from './CodeInput.constants';
export { CodeInputType } from './CodeInput.types';
7 changes: 4 additions & 3 deletions src/components/InputField/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ const InputField = (
disabled = false,
endAdornment,
error,
errorMsg,
forceTheme,
ghost = false,
helperText,
Expand Down Expand Up @@ -139,7 +138,7 @@ const InputField = (
$paddingRight={paddingRight}
readOnly={readOnly}
$active={!!active}
$error={!!error || !!errorMsg}
$error={!!error}
$size={size}
$ghost={ghost}
$forceTheme={forceTheme}
Expand All @@ -156,7 +155,9 @@ const InputField = (
</EndAdornment>
)}
</InputFieldContainer>
<SubText errorMsg={errorMsg} helperText={helperText} size={size} forceTheme={forceTheme} />
{typeof error === 'string' && (
<SubText errorMsg={error} helperText={helperText} size={size} forceTheme={forceTheme} />
)}
</Wrapper>
);
};
Expand Down
6 changes: 2 additions & 4 deletions src/components/InputField/InputField.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ export interface InputFieldProps {
dataTest?: string;
/** Disable editing */
disabled?: boolean;
/** Error state */
error?: boolean;
/** Error message */
errorMsg?: string;
/** Error state / message */
error?: boolean | string;
/** Override theme */
forceTheme?: ThemeMode;
/**
Expand Down
7 changes: 4 additions & 3 deletions src/components/InputField/TextArea/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ const TextArea = (
dataTest,
disabled = false,
error,
errorMsg,
forceTheme,
ghost = false,
helperText,
Expand Down Expand Up @@ -118,7 +117,7 @@ const TextArea = (
readOnly={readOnly}
$active={!!active}
$dynamicHeight={dynamicHeight}
$error={!!error || !!errorMsg}
$error={!!error}
$size={size}
$startIconExists={!!icon}
$ghost={ghost}
Expand All @@ -128,7 +127,9 @@ const TextArea = (
$borderRadius={borderRadius}
/>
</TextAreaContainer>
<SubText errorMsg={errorMsg} helperText={helperText} size={size} forceTheme={forceTheme} />
{typeof error === 'string' && (
<SubText errorMsg={error} helperText={helperText} size={size} forceTheme={forceTheme} />
)}
</Wrapper>
);
};
Expand Down