cleanup, few fixes

This commit is contained in:
Davor Hrg
2021-08-06 11:22:09 +02:00
parent 80b12a6e3a
commit e851593c12
5 changed files with 10 additions and 5 deletions

View File

@@ -14,7 +14,6 @@ const Customizer = () => {
const handleRender2 = ()=>handleRender(getParams(ref.current))
React.useEffect(() => {
console.log({ jsCadCustomizerElement, customizerParams, lastParameters })
if (jsCadCustomizerElement && customizerParams) {
genParams(customizerParams, jsCadCustomizerElement, lastParameters || {}, (values, source)=>{
if(source === 'group'){

View File

@@ -109,7 +109,6 @@ export const render: DefaultKernelExport['render'] = async ({
if (data.error) {
response = createUnhealthyResponse(new Date(), data.error)
} else {
console.log('lastParameters',lastParameters)
response = createHealthyResponse({
type: 'geometry',
data: [...data.entities.map(CSG2Object3D).filter((o) => o)],

View File

@@ -51,7 +51,7 @@ export function genParams(defs, target, storedParams={}, callback=undefined, but
let ret = '<div type="radio">'
for(let i =0; i<values.length; i++){
let checked = (value == values[i] || value == captions[i] ) ? 'selected':''
let checked = (value == values[i] || value == captions[i] ) ? 'checked':''
ret += `<label><input type="radio" _type="${type}" name="${name}" numeric="${typeof values[0] == 'number' ? '1':'0'}" value="${values[i]}" ${checked}/>${captions[i]}</label>`
}
return ret +'</div>'
@@ -182,6 +182,9 @@ export function getParams(target){
}
if(numeric[elem.getAttribute('type')] || elem.getAttribute('numeric') == '1') value = parseFloat(value || 0)
if(elem.type == 'radio' && !elem.checked) return // skip if not checked radio button
params[name] = value
})
return params;

View File

@@ -86,7 +86,7 @@ const getParameterDefinitions = ()=>{
{ name: 'slider', type: 'slider', initial: 3, min: 1, max: 10, step: 1, caption: 'Slider:' },
{ name: 'choice1', type: 'choice', caption: 'Dropdown Menu:', values: [0, 1, 2, 3], captions: ['No', 'Yes', 'Maybe', 'So so'], initial: 2 },
{ name: 'choice3', type: 'choice', caption: 'Dropdown Menu:', values: ['No', 'Yes', 'Maybe', 'So so'], initial: 'No' },
{ name: 'choice2', type: 'radio', caption: 'Radio Buttons:', values:[0, 1, 2, 3], captions: ['No', 'Yes', 'Maybe', 'So so'], initial: 5 },
{ name: 'choice2', type: 'radio', caption: 'Radio Buttons:', values:[0, 1, 2, 3], captions: ['No', 'Yes', 'Maybe', 'So so'], initial: 2 },
{ name: 'group3', type: 'group', initial: 'closed', caption: 'Group 3: Initially Closed Group' },
{ name: 'checkbox2', type: 'checkbox', checked: true, initial: '20', caption: 'Optional Checkbox:' },

View File

@@ -179,6 +179,10 @@ input.error, textarea.error {
display: inline-block;
margin-left: 10px;
}
#jscad-customizer-block > .form-line[type="checkbox"] > label > input{
position: absolute;
right: 14px;
}
#jscad-customizer-block > .form-line > label i{
display: none;