Skip to content

Commit

Permalink
WIP #2: Added propTypes and directional icons.
Browse files Browse the repository at this point in the history
  • Loading branch information
BaibhaVatsa committed Nov 27, 2019
1 parent 6ea1be9 commit 6f3ed96
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/components/ArrowComponent.tsx
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;

0 comments on commit 6f3ed96

Please sign in to comment.