-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into ryan-kathleen-implement-search-bar-in-announc…
…ements-page
- Loading branch information
Showing
27 changed files
with
1,160 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import React from "react"; | ||
import { | ||
Button, | ||
Input, | ||
Flex, | ||
FormControl, | ||
FormLabel, | ||
InputRightElement, | ||
InputGroup, | ||
InputLeftElement, | ||
} from "@chakra-ui/react"; | ||
|
||
import VisibilityIcon from "@mui/icons-material/Visibility"; | ||
import VisibilityOffIcon from "@mui/icons-material/VisibilityOff"; | ||
|
||
const FormField = ({ | ||
label, | ||
value, | ||
type = "text", | ||
onChange, | ||
onBlur, | ||
submitPressed, | ||
required = false, | ||
error = false, | ||
isPassword = false, | ||
showPassword, | ||
setShowPassword, | ||
leftElement, | ||
}: { | ||
label: string; | ||
value: string; | ||
type?: string; | ||
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void; | ||
onBlur?: () => void; | ||
submitPressed: boolean; | ||
required?: boolean; | ||
error?: boolean; | ||
isPassword?: boolean; | ||
showPassword?: boolean; | ||
setShowPassword?: React.Dispatch<React.SetStateAction<boolean>>; | ||
leftElement?: string; | ||
}) => ( | ||
<Flex flexDir="column" flex="1"> | ||
<FormControl isRequired={required}> | ||
<FormLabel mb="5px" color="gray.main" fontWeight="700"> | ||
{label} | ||
</FormLabel> | ||
<InputGroup> | ||
{leftElement && ( | ||
<InputLeftElement height="34px" pointerEvents="none" color="black"> | ||
<Flex>{leftElement}</Flex> | ||
</InputLeftElement> | ||
)} | ||
|
||
<Input | ||
variant="primary" | ||
placeholder="" | ||
borderColor={ | ||
error || (submitPressed && !value && required) | ||
? "red.error" | ||
: "gray.300" | ||
} | ||
boxShadow={ | ||
error || (submitPressed && !value && required) | ||
? "0 0 2px red.error" | ||
: "none" | ||
} | ||
type={ | ||
isPassword && setShowPassword && !showPassword ? "password" : type | ||
} | ||
value={value} | ||
onChange={onChange} | ||
onBlur={onBlur} | ||
/> | ||
{isPassword && setShowPassword && ( | ||
<InputRightElement h="34px"> | ||
<Button | ||
onClick={() => setShowPassword(!showPassword)} | ||
bg="transparent" | ||
_hover={{ bg: "transparent" }} | ||
> | ||
{!showPassword ? ( | ||
<VisibilityIcon fontSize="small" /> | ||
) : ( | ||
<VisibilityOffIcon fontSize="small" /> | ||
)} | ||
</Button> | ||
</InputRightElement> | ||
)} | ||
</InputGroup> | ||
</FormControl> | ||
</Flex> | ||
); | ||
|
||
export default FormField; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.