Merged PR 17: Implement rigid body Fix multiple bugs

Implement rigid body

Fix saveload bug: having null elements
Fix events being duplicated and not being removed
This commit is contained in:
Eric Nguyen 2022-08-11 08:43:10 +00:00
parent d2e1d9f0a4
commit 616fe3e9ac
22 changed files with 804 additions and 95 deletions

View file

@ -1,9 +1,10 @@
import * as React from 'react';
import ContainerProperties from '../../Interfaces/Properties';
import { INPUT_TYPES } from './PropertiesInputTypes';
interface IPropertiesProps {
properties?: ContainerProperties
onChange: (key: string, value: string) => void
onChange: (key: string, value: string | number | boolean) => void
}
export const Properties: React.FC<IPropertiesProps> = (props: IPropertiesProps) => {
@ -26,11 +27,24 @@ export const Properties: React.FC<IPropertiesProps> = (props: IPropertiesProps)
const handleProperties = (
[key, value]: [string, string | number],
groupInput: React.ReactNode[],
onChange: (key: string, value: string) => void
onChange: (key: string, value: string | number | boolean) => void
): void => {
const id = `property-${key}`;
const type = 'text';
const isDisabled = key === 'id' || key === 'parentId'; // hardcoded
let type = 'text';
let checked;
/// hardcoded stuff for ergonomy ///
if (typeof value === 'boolean') {
checked = value;
}
if (key in INPUT_TYPES) {
type = INPUT_TYPES[key];
}
const isDisabled = ['id', 'parentId'].includes(key);
///
groupInput.push(
<div key={id} className='mt-4'>
<label className='text-sm font-medium text-gray-800' htmlFor={id}>{key}</label>
@ -43,7 +57,14 @@ const handleProperties = (
type={type}
id={id}
value={value}
onChange={(event) => onChange(key, event.target.value)}
checked={checked}
onChange={(event) => {
if (type === 'checkbox') {
onChange(key, event.target.checked);
return;
}
onChange(key, event.target.value);
}}
disabled={isDisabled}
/>
</div>