~comcloudway/cora

03e7e69acb4efacf51c85b27ce413aaac752b195 — Jakob Meier 1 year, 1 month ago a83b408 main
Fixed dropdowns not updating / showing initial value
M package-lock.json => package-lock.json +13 -1
@@ 8,7 8,8 @@
			"dependencies": {
				"react": "^18.2.0",
				"react-stl-viewer": "^2.3",
				"three": "0.154.0"
				"three": "0.154.0",
				"typescript-language-server": "^3.3.2"
			},
			"devDependencies": {
				"@vitejs/plugin-react": "^4.0.4",


@@ 1611,6 1612,17 @@
				"node": ">=4"
			}
		},
		"node_modules/typescript-language-server": {
			"version": "3.3.2",
			"resolved": "https://registry.npmjs.org/typescript-language-server/-/typescript-language-server-3.3.2.tgz",
			"integrity": "sha512-jzun53CIkTbpAki0nP+hk5baGW+86SNNlVhyIj2ZUy45zUkCnmoetWuAtfRRQYrlIr8x4QB3ymGJPuwDQSd/ew==",
			"bin": {
				"typescript-language-server": "lib/cli.mjs"
			},
			"engines": {
				"node": ">=14.17"
			}
		},
		"node_modules/update-browserslist-db": {
			"version": "1.0.11",
			"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.11.tgz",

M package.json => package.json +2 -1
@@ 10,7 10,8 @@
	"dependencies": {
		"react": "^18.2.0",
		"react-stl-viewer": "^2.3",
		"three": "0.154.0"
		"three": "0.154.0",
		"typescript-language-server": "^3.3.2"
	},
	"devDependencies": {
		"@vitejs/plugin-react": "^4.0.4",

M src/screens/editor.jsx => src/screens/editor.jsx +3 -3
@@ 39,7 39,7 @@ export function Editor({ content:[content, set_content], file_path }) {
	const pages = [
		["Edit", "Adjust model parameters"], 
		["Preview","Render & View the model"],
		["Export", "Download the model or import/export presets"]
		["File", "Download the model or import/export presets"]
	];
	const [page, set_page] = useState(pages[0][0]);



@@ 48,7 48,7 @@ export function Editor({ content:[content, set_content], file_path }) {
		  {/* NAVBAR controlled using page & pages */}
		  <header>
		    <nav>
		      <a href="" title="Close the currently opened project">Exit</a>
		      <a href="" title="Close the currently opened project">Close</a>

		      { pages.map(
			      ([title, description])=>


@@ 70,7 70,7 @@ export function Editor({ content:[content, set_content], file_path }) {
		  { page=="Preview" &&
        <Preview render={render} stl={stl}/>}

		  { page=="Export" &&
		  { page=="File" &&
        <Export
			    set_is_generating={set_is_generating}
			    project_name={project_name}

M src/screens/editor/edit.jsx => src/screens/editor/edit.jsx +6 -4
@@ 17,9 17,12 @@ function Slider({ onUpdate=(_)=>{}, min, max, step, value }) {
	);
}

function DropDown({ onUpdate=(_)=>{}, options=[], id:key }) {
function DropDown({ onUpdate=(_)=>{}, options=[], id:key, value }) {
	return (
		<select onSelect={e=>onUpdate(e.target.value)}>
		<select 
			onSelect={e=>onUpdate(e.target.value)}
			defaultValue={value}
		>
		  { options.map(
			  ({name, value})=>(<option
				     key={`${key}-select-${value}`}


@@ 104,19 107,18 @@ export function Edit({ content:[content, set_content], model }) {
												          let scad = apply(content, name, title, v);
												          set_content(scad);
											          },
																value,
											          ...((itype=="text")?{
												          // extra config for text box
												          type,
												          title,
												          visualizer,
												          value
											          }:{}),
											          ...((itype=="slider")?{
												          // extra config for slider
												          min:visualizer.min,
												          max:visualizer.max,
												          step:visualizer.step,
												          value
											          }:{}),
											          ...((itype=="dropdown")?{
												          // extra config for drop down

M src/screens/editor/export.jsx => src/screens/editor/export.jsx +5 -1
@@ 111,7 111,11 @@ export function Export({ content:[content, set_content], project_name, set_is_ge
            reader.onerror=()=>alert("Unable to read preset");
            reader.readAsText(file);
          }}/>
          <select onSelect={e=>set_template_name(e.target.value)}>
					<div style={{marginLeft: "0.4rem"}}></div>
          <select
						onSelect={e=>set_template_name(e.target.value)}
						style={{margin: "0 0.8rem"}}
					>
            { Object.keys(template_json)
                    .map(id=>(
                      <option key={`json-${id}`} value={id}>{id}</option>)) }