From b272078f99ad8b65bd5ed8c009bde35d7db7eef7 Mon Sep 17 00:00:00 2001 From: Samuel Rowe Date: Fri, 29 Jul 2022 14:28:28 +0530 Subject: [PATCH] feat(frontend): updated toggles to be optionally empty --- .../components/global/FormElements/Toggle.tsx | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/services/frontend/src/components/global/FormElements/Toggle.tsx b/services/frontend/src/components/global/FormElements/Toggle.tsx index c30dd01..5c2f426 100644 --- a/services/frontend/src/components/global/FormElements/Toggle.tsx +++ b/services/frontend/src/components/global/FormElements/Toggle.tsx @@ -33,6 +33,10 @@ const ToggleButton = styled(Button)(({ index, total }) => ({ fontSize: 11 })); +const ButtonBorder = styled("div")` + border-right: 1px solid white; +`; + const Toggle: FunctionComponent = ( props: IToggleProps ): ReactElement => { @@ -42,23 +46,26 @@ const Toggle: FunctionComponent = ( lodash.get(formik.touched, name) && lodash.get(formik.errors, name); const value = lodash.get(formik.values, name); - const handleChange = (value: string) => () => { - formik.setFieldValue(name, value); + const handleChange = (newValue: string) => () => { + formik.setFieldValue(name, newValue === value ? "" : newValue); }; return ( {options.map((option, index) => ( - - {option.text} - + <> + + {option.text} + + {index + 1 < options.length && } + ))}