Skip to content

Commit

Permalink
WIP #2: Added disabled to props and moved to TypeScript types instead…
Browse files Browse the repository at this point in the history
… of JavaScript ones
  • Loading branch information
BaibhaVatsa committed Nov 28, 2019
1 parent 6f3ed96 commit 8d3f7c9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/components/ArrowComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ import ChevronLeftIcon from '@material-ui/icons/ChevronLeft';
import ChevronRightIcon from '@material-ui/icons/ChevronRight';

type ArrowProps = {
handleClick: (direction: Number) => void;
direction: String;
handleClick: (direction: number) => void;
direction: string;
disabled: boolean;
}

const ArrowComponent: React.FC<ArrowProps> = (props: ArrowProps) => {
const directionNumber = (props.direction === "right") ? 1 : -1;
return (
<div>
<Fab size='large' aria-label='add' variant='extended'
onClick={() => props.handleClick(directionNumber)}>
onClick={() => props.handleClick(directionNumber)}
disabled={props.disabled}>
{(directionNumber == 1) ? <ChevronRightIcon /> : <ChevronLeftIcon />}
</Fab>
</div>
Expand All @@ -23,7 +25,8 @@ const ArrowComponent: React.FC<ArrowProps> = (props: ArrowProps) => {

ArrowComponent.propTypes = {
handleClick: PropType.func.isRequired,
direction: PropType.instanceOf(String).isRequired
direction: PropType.string.isRequired,
disabled: PropType.bool.isRequired,
}

export default ArrowComponent;

0 comments on commit 8d3f7c9

Please sign in to comment.