From 8dd8e2e749cfd7049c4e4ecc9c6512e477edb4fa Mon Sep 17 00:00:00 2001 From: Kurt Hutten Date: Sat, 7 Aug 2021 19:24:49 +1000 Subject: [PATCH] Tweak customizer styles and hide on non-jscad screens --- .../src/components/Customizer/Customizer.tsx | 72 +++++++++++++------ 1 file changed, 49 insertions(+), 23 deletions(-) diff --git a/app/web/src/components/Customizer/Customizer.tsx b/app/web/src/components/Customizer/Customizer.tsx index 9010328..d418538 100644 --- a/app/web/src/components/Customizer/Customizer.tsx +++ b/app/web/src/components/Customizer/Customizer.tsx @@ -1,10 +1,12 @@ import { useRender } from 'src/components/IdeWrapper/useRender' import { useIdeContext } from 'src/helpers/hooks/useIdeContext' import { genParams } from 'src/helpers/cadPackages/jsCad/jscadParams' +import { Switch } from '@headlessui/react' +import Svg from 'src/components/Svg/Svg' const Customizer = () => { - const [open, setOpen] = React.useState(true) - const [checked, setChecked] = React.useState(false) + const [open, setOpen] = React.useState(false) + const [shouldLiveUpdate, setShouldLiveUpdate] = React.useState(false) const ref = React.useRef() const jsCadCustomizerElement = ref.current const { state, thunkDispatch } = useIdeContext() @@ -20,14 +22,20 @@ const Customizer = () => { currentParameters || {}, (values, source) => { thunkDispatch({ type: 'setCurrentCustomizerParams', payload: values }) - if (checked) { + if (shouldLiveUpdate) { handleRender() } }, [] ) } - }, [jsCadCustomizerElement, customizerParams, currentParameters, checked]) + }, [ + jsCadCustomizerElement, + customizerParams, + currentParameters, + shouldLiveUpdate, + ]) + if (!state.customizerParams) return null return (
{
Parameters
-
- { - const newValue = !checked - if (newValue) handleRender() - setChecked(newValue) - }} - /> - -
+ {open && ( + <> +
+
Auto Update
+ { + setShouldLiveUpdate + if (newValue) handleRender() + setShouldLiveUpdate(newValue) + }} + className={`${ + shouldLiveUpdate ? 'bg-ch-purple-600' : 'bg-ch-gray-300' + } relative inline-flex items-center h-6 rounded-full w-11 mr-6`} + > + + + +
+ + )}