From 6f3ed96e53b299cf9996a739fb36d76295973d24 Mon Sep 17 00:00:00 2001 From: Baibhav Vatsa Date: Wed, 27 Nov 2019 09:52:57 -0600 Subject: [PATCH 1/5] WIP #2: Added propTypes and directional icons. --- src/components/ArrowComponent.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/ArrowComponent.tsx b/src/components/ArrowComponent.tsx index 28f773a..1b9f0ba 100644 --- a/src/components/ArrowComponent.tsx +++ b/src/components/ArrowComponent.tsx @@ -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) => void; - suppliedIcon: JSX.Element; + handleClick: (direction: Number) => void; + direction: String; } const ArrowComponent: React.FC = (props: ArrowProps) => { + const directionNumber = (props.direction === "right") ? 1 : -1; return (
- - {props.suppliedIcon} + props.handleClick(directionNumber)}> + {(directionNumber == 1) ? : }
); } ArrowComponent.propTypes = { - // TODO add suppliedIcon and handleClick + handleClick: PropType.func.isRequired, + direction: PropType.instanceOf(String).isRequired } export default ArrowComponent; \ No newline at end of file From 8d3f7c98e4ff2e0310d97eb263575797056b89d5 Mon Sep 17 00:00:00 2001 From: Baibhav Vatsa Date: Thu, 28 Nov 2019 03:04:17 -0600 Subject: [PATCH 2/5] WIP #2: Added disabled to props and moved to TypeScript types instead of JavaScript ones --- src/components/ArrowComponent.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/ArrowComponent.tsx b/src/components/ArrowComponent.tsx index 1b9f0ba..99c1662 100644 --- a/src/components/ArrowComponent.tsx +++ b/src/components/ArrowComponent.tsx @@ -5,8 +5,9 @@ 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 = (props: ArrowProps) => { @@ -14,7 +15,8 @@ const ArrowComponent: React.FC = (props: ArrowProps) => { return (
props.handleClick(directionNumber)}> + onClick={() => props.handleClick(directionNumber)} + disabled={props.disabled}> {(directionNumber == 1) ? : }
@@ -23,7 +25,8 @@ const ArrowComponent: React.FC = (props: ArrowProps) => { ArrowComponent.propTypes = { handleClick: PropType.func.isRequired, - direction: PropType.instanceOf(String).isRequired + direction: PropType.string.isRequired, + disabled: PropType.bool.isRequired, } export default ArrowComponent; \ No newline at end of file From 5c214c3dd00e5b30ef02c7c205037ef265168a97 Mon Sep 17 00:00:00 2001 From: Baibhav Vatsa Date: Thu, 28 Nov 2019 03:17:52 -0600 Subject: [PATCH 3/5] WIP #2: Added styling to arrows --- src/components/ArrowComponent.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/ArrowComponent.tsx b/src/components/ArrowComponent.tsx index 99c1662..a0772a3 100644 --- a/src/components/ArrowComponent.tsx +++ b/src/components/ArrowComponent.tsx @@ -10,13 +10,16 @@ type ArrowProps = { disabled: boolean; } +const vanillaArrowStyle = {boxShadow: "none", background: "#f4f4f4"} + const ArrowComponent: React.FC = (props: ArrowProps) => { const directionNumber = (props.direction === "right") ? 1 : -1; return (
- props.handleClick(directionNumber)} - disabled={props.disabled}> + disabled={props.disabled} + style={vanillaArrowStyle}> {(directionNumber == 1) ? : }
From abe0065a7cac1f3edeb1c5248f18bf187c6b2286 Mon Sep 17 00:00:00 2001 From: Baibhav Vatsa Date: Thu, 28 Nov 2019 03:19:03 -0600 Subject: [PATCH 4/5] WIP #2: Minor formatting changes --- src/components/ArrowComponent.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/ArrowComponent.tsx b/src/components/ArrowComponent.tsx index a0772a3..81f5874 100644 --- a/src/components/ArrowComponent.tsx +++ b/src/components/ArrowComponent.tsx @@ -10,7 +10,10 @@ type ArrowProps = { disabled: boolean; } -const vanillaArrowStyle = {boxShadow: "none", background: "#f4f4f4"} +const vanillaArrowStyle = { + boxShadow: "none", + background: "#f4f4f4" +} const ArrowComponent: React.FC = (props: ArrowProps) => { const directionNumber = (props.direction === "right") ? 1 : -1; From 4ce56330cae993de07a9d70069543660565a8ff9 Mon Sep 17 00:00:00 2001 From: Baibhav Vatsa Date: Sun, 15 Dec 2019 19:37:48 -0600 Subject: [PATCH 5/5] WIP #2: Uses === instead of == now --- src/components/ArrowComponent.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ArrowComponent.tsx b/src/components/ArrowComponent.tsx index 81f5874..4e3ae69 100644 --- a/src/components/ArrowComponent.tsx +++ b/src/components/ArrowComponent.tsx @@ -23,7 +23,7 @@ const ArrowComponent: React.FC = (props: ArrowProps) => { onClick={() => props.handleClick(directionNumber)} disabled={props.disabled} style={vanillaArrowStyle}> - {(directionNumber == 1) ? : } + {(directionNumber === 1) ? : } );