Skip to content

Commit

Permalink
minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
DejayJD committed Oct 12, 2023
1 parent a55cf3a commit 1177a60
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions packages/harmony/src/components/input/TextInput/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ export enum TextInputSize {
DEFAULT = 'default'
}

export type TextInputProps = Omit<ComponentPropsWithoutRef<'input'>, 'size'> & {
export type TextInputProps = Omit<
ComponentPropsWithoutRef<'input'>,
// Omitting required purely for storybook docs
'size' | 'required'
> & {
/**
* Input sizes. NOTE: small inputs will not show the label
* @default default
*/
size?: TextInputSize
/**
* Show a "x/Max" text displaying number of characters allowed
* @default false
*/
showMaxLength?: boolean
/**
Expand Down Expand Up @@ -66,6 +69,10 @@ export type TextInputProps = Omit<ComponentPropsWithoutRef<'input'>, 'size'> & {
* Floating text on the righthand side of the input
*/
endIcon?: IconComponent
/**
* Required or not. Will add an * to the label if required
*/
required?: boolean
}

export const TextInput = forwardRef<HTMLInputElement, TextInputProps>(
Expand Down Expand Up @@ -130,7 +137,7 @@ export const TextInput = forwardRef<HTMLInputElement, TextInputProps>(
[styles.required]: required
}

const input = (
const inputRender = (
<div className={cn(styles.inputRow, layoutStyles.row)}>
<div className={cn(layoutStyles.row, styles.inputContainer)}>
{startAdornmentText ? (
Expand Down Expand Up @@ -176,10 +183,10 @@ export const TextInput = forwardRef<HTMLInputElement, TextInputProps>(
>
{label}
</Text>
{input}
{inputRender}
</label>
) : (
input
inputRender
)}

{showMaxLength && (
Expand Down

0 comments on commit 1177a60

Please sign in to comment.