-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from uwblueprint/julia-cindy/tasks-modal
Create Tasks Modal Component
- Loading branch information
Showing
7 changed files
with
358 additions
and
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import React from "react"; | ||
import { | ||
Button, | ||
Input, | ||
Select, | ||
Flex, | ||
FormControl, | ||
FormLabel, | ||
InputRightElement, | ||
InputGroup, | ||
InputLeftElement, | ||
Checkbox, | ||
Container, | ||
} 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, | ||
isPassword = false, | ||
showPassword, | ||
setShowPassword, | ||
leftElement | ||
}: { | ||
label: string; | ||
value: string; | ||
type?: string; | ||
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void; | ||
onBlur?: () => void; | ||
submitPressed: boolean; | ||
required?: 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='Enter amount' | ||
borderColor={submitPressed && !value ? "red.error" : "gray.300"} | ||
boxShadow={submitPressed && !value ? "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.