Skip to content

Commit

Permalink
feat: add warning props to inputGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
karinamaulitova committed Feb 21, 2024
1 parent f5aaa4d commit c90a1ff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/input/InputGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@ import { InputGroupProps } from './types.js'

export const InputGroup = forwardRef(
(
{ fullwidth = false, error, success, children, ...rest }: InputGroupProps,
{
fullwidth = false,
error,
success,
warning,
children,
...rest
}: InputGroupProps,
ref?: ForwardedRef<HTMLSpanElement>,
) => {
const hasError = !!error
const hasSuccess = !!success && !error
const hasWarning = !hasError && !!warning // `error` overrides `warning`

return (
<InputGroupStyle $fullwidth={fullwidth} {...rest} ref={ref}>
Expand All @@ -20,6 +28,9 @@ export const InputGroup = forwardRef(
{hasSuccess && (
<InputMessageStyle $variant='success'>{success}</InputMessageStyle>
)}
{hasWarning && (
<InputMessageStyle $variant='warning'>{warning}</InputMessageStyle>
)}
</InputGroupStyle>
)
},
Expand Down
1 change: 1 addition & 0 deletions packages/input/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export type InputGroupProps = LidoComponentProps<
fullwidth?: boolean
error?: ReactNode
success?: ReactNode
warning?: ReactNode
}
>

Expand Down

0 comments on commit c90a1ff

Please sign in to comment.