diff --git a/app/web/package.json b/app/web/package.json index c13f7f6..a3459c1 100644 --- a/app/web/package.json +++ b/app/web/package.json @@ -14,6 +14,7 @@ }, "dependencies": { "@headlessui/react": "^1.0.0", + "@heroicons/react": "^1.0.4", "@material-ui/core": "^4.11.0", "@monaco-editor/react": "^4.0.11", "@react-three/drei": "^7.3.1", diff --git a/app/web/public/demo-worker.js b/app/web/public/demo-worker.js index 63160e1..f49e365 100644 --- a/app/web/public/demo-worker.js +++ b/app/web/public/demo-worker.js @@ -271,7 +271,7 @@ function parseParams(script){ caption = caption.substring(0,idx).trim() } defs.push({name, type: 'group', caption, ...def.options}) - + }else{ const idx = line.indexOf('/') if(idx === -1){ @@ -316,7 +316,7 @@ function parseComment(comment, line){ const prefix = comment.substring(0,2) if(prefix === '//') comment = comment.substring(2) if(prefix === '/*') comment = comment.substring(2, comment.length-2) - + comment = comment.trim() const ret = {} @@ -331,7 +331,7 @@ function parseComment(comment, line){ } comment = comment.substring(0,idx).trim() } - + ret.caption = comment return ret @@ -347,7 +347,7 @@ function parseDef(code, line){ return {name:code, type:'text'} }else{ let initial = code.substring(idx+1).trim() - + const ret = {type:'text', name:code.substring(0,idx).trim()} if(initial === 'true' || initial === 'false'){ @@ -394,7 +394,7 @@ const makeScriptWorker = ({callback, convertToSolids})=>{ solids = [] function flatten(arr){ if(arr){ - if(arr instanceof Array) + if(arr instanceof Array) arr.forEach(flatten) else solids.push(arr) @@ -454,7 +454,6 @@ const makeScriptWorker = ({callback, convertToSolids})=>{ } }) } - console.log('paramsDef', paramsDef) if(paramsDef.length) callback({action:'parameterDefinitions', worker:'main', data:paramsDef}) runMain(params) diff --git a/app/web/src/components/Customizer/Customizer.tsx b/app/web/src/components/Customizer/Customizer.tsx index 657faa2..455df78 100644 --- a/app/web/src/components/Customizer/Customizer.tsx +++ b/app/web/src/components/Customizer/Customizer.tsx @@ -1,3 +1,6 @@ +import { Listbox, Transition } from '@headlessui/react' +import { CheckIcon, SelectorIcon } from '@heroicons/react/solid' + import { useRender } from 'src/components/IdeWrapper/useRender' import { useIdeContext } from 'src/helpers/hooks/useIdeContext' import { Switch } from '@headlessui/react' @@ -139,7 +142,7 @@ function BooleanParam({ }: { param: CadhubBooleanParam value: any - onChange: Function + onChange: (value: any) => void }) { return ( @@ -169,7 +172,7 @@ function StringParam({ }: { param: CadhubStringParam value: any - onChange: Function + onChange: (value: any) => void }) { return ( @@ -191,21 +194,68 @@ function ChoiceParam({ }: { param: CadhubStringChoiceParam | CadhubNumberChoiceParam value: any - onChange: Function + onChange: (value: any) => void }) { return ( - + +
+ + {value} + + + + + + {param.options.map((option, optionIdx) => ( + + `${ + active + ? 'text-ch-blue-600 bg-ch-gray-700' + : 'text-ch-gray-300' + } + cursor-default select-none relative py-2 pl-10 pr-4` + } + value={option.value} + > + {({ selected, active }) => ( + <> + + {option.name} + + {selected ? ( + + + ) : null} + + )} + + ))} + + +
+
) } @@ -217,7 +267,7 @@ function NumberParam({ }: { param: CadhubNumberParam value: any - onChange: Function + onChange: (value: any) => void }) { const [isFocused, isFocusedSetter] = React.useState(false) const [localValue, localValueSetter] = React.useState(0) diff --git a/app/yarn.lock b/app/yarn.lock index b08454c..0d94e72 100644 --- a/app/yarn.lock +++ b/app/yarn.lock @@ -1917,6 +1917,11 @@ resolved "https://registry.yarnpkg.com/@headlessui/react/-/react-1.2.0.tgz#e48652bfce82ddf73d7f331faeb9db6526ee6874" integrity sha512-19DkLz8gDgbi+WvkoTzi9vs0NK9TJf94vbYhMzB4LYJo03Kili0gmvXT9CiKZoxXZ7YAvy/b1U1oQKEnjWrqxw== +"@heroicons/react@^1.0.4": + version "1.0.4" + resolved "https://registry.yarnpkg.com/@heroicons/react/-/react-1.0.4.tgz#11847eb2ea5510419d7ada9ff150a33af0ad0863" + integrity sha512-3kOrTmo8+Z8o6AL0rzN82MOf8J5CuxhRLFhpI8mrn+3OqekA6d5eb1GYO3EYYo1Vn6mYQSMNTzCWbEwUInb0cQ== + "@iarna/toml@^2.2.5": version "2.2.5" resolved "https://registry.yarnpkg.com/@iarna/toml/-/toml-2.2.5.tgz#b32366c89b43c6f8cefbdefac778b9c828e3ba8c"