-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP #2: Added propTypes and directional icons.
- Loading branch information
1 parent
6ea1be9
commit 6f3ed96
Showing
1 changed file
with
10 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
import React from 'react'; | ||
import PropType from 'prop-types'; | ||
import { Fab } from '@material-ui/core'; | ||
import ChevronLeftIcon from '@material-ui/icons/ChevronLeft'; | ||
import ChevronRightIcon from '@material-ui/icons/ChevronRight'; | ||
|
||
type ArrowProps = { | ||
// TODO check for MouseEvent | ||
handleClick: (event: React.MouseEvent<HTMLButtonElement>) => void; | ||
suppliedIcon: JSX.Element; | ||
handleClick: (direction: Number) => void; | ||
direction: String; | ||
} | ||
|
||
const ArrowComponent: React.FC<ArrowProps> = (props: ArrowProps) => { | ||
const directionNumber = (props.direction === "right") ? 1 : -1; | ||
return ( | ||
<div> | ||
<Fab size='large' aria-label='add' variant='extended'> | ||
{props.suppliedIcon} | ||
<Fab size='large' aria-label='add' variant='extended' | ||
onClick={() => props.handleClick(directionNumber)}> | ||
{(directionNumber == 1) ? <ChevronRightIcon /> : <ChevronLeftIcon />} | ||
</Fab> | ||
</div> | ||
); | ||
} | ||
|
||
ArrowComponent.propTypes = { | ||
// TODO add suppliedIcon and handleClick | ||
handleClick: PropType.func.isRequired, | ||
direction: PropType.instanceOf(String).isRequired | ||
} | ||
|
||
export default ArrowComponent; |