Skip to content

Commit

Permalink
feat: added input inline error message
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasconstantino committed Jun 13, 2022
1 parent d53abb1 commit 40bd123
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/features/ui/components/Input/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import {
InputWrapper,
Label,
LabelText,
ErrorMessage,
PasswordToggle,
StyledInput,
} from './styled'

type Props = InputHTMLAttributes<HTMLInputElement> & {
label: string
error?: string
error?: string | null
}

export const Input: FC<Props> = ({ label, name, type, error, ...rest }) => {
Expand Down Expand Up @@ -40,6 +41,8 @@ export const Input: FC<Props> = ({ label, name, type, error, ...rest }) => {
<EyeIcon />
</PasswordToggle>
)}

{error ? <ErrorMessage>{error}</ErrorMessage> : null}
</Label>
</InputWrapper>
)
Expand Down
4 changes: 4 additions & 0 deletions src/features/ui/components/Input/styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ export const Label = styled.label<{ hasError?: boolean }>`
`}
`

export const ErrorMessage = styled.span`
color: ${colors.accent.destructive};
`

export const PasswordToggle = styled.button.attrs({ type: 'button' })<{
isActive: boolean
}>`
Expand Down

0 comments on commit 40bd123

Please sign in to comment.