diff options
| author | 2021-01-18 17:58:01 +0200 | |
|---|---|---|
| committer | 2021-01-18 17:58:01 +0200 | |
| commit | 2d7c77048609f97e0b94d7cb0d8c859a95e07285 (patch) | |
| tree | 3df3cf332317ed3c3147a268dec053c57cb0f76c /src | |
| parent | Add required validator for ShortText (diff) | |
Implement validation to ShortText component
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/InputTypes/ShortText.tsx | 13 | 
1 files changed, 9 insertions, 4 deletions
| diff --git a/src/components/InputTypes/ShortText.tsx b/src/components/InputTypes/ShortText.tsx index d34bd01..5509a45 100644 --- a/src/components/InputTypes/ShortText.tsx +++ b/src/components/InputTypes/ShortText.tsx @@ -1,13 +1,18 @@  /** @jsx jsx */  import { jsx } from "@emotion/react"; -import React, { ChangeEvent } from "react"; -import { textInputs } from "../../commonStyles"; +import React, { ChangeEvent, FocusEvent } from "react"; +import { textInputs, invalidStyles } from "../../commonStyles";  interface ShortTextProps {      handler: (event: ChangeEvent<HTMLInputElement>) => void, -    required: boolean +    blurHandler: (event: FocusEvent<HTMLInputElement>) => void, +    valid: boolean  }  export default function ShortText(props: ShortTextProps): JSX.Element { -    return <input type="text" css={textInputs} placeholder="Enter Text..." onChange={props.handler}/>; +    return ( +        <div css={invalidStyles}> +            <input type="text" css={textInputs} placeholder="Enter Text..." onChange={props.handler} onBlur={props.blurHandler} className={!props.valid ? "invalid-box" : ""}/> +        </div> +    );  } | 
