refactor: type renderers

This commit is contained in:
cha0s 2020-06-19 19:21:02 -05:00
parent faea819945
commit 3664828331
9 changed files with 9 additions and 25 deletions

View File

@ -81,8 +81,6 @@ const makeTabSelector = (context, type) => createSelector(
<Component
context={context}
key={key}
label={label}
name={key}
options={options}
value={values[key]}
/>

View File

@ -13,9 +13,6 @@ const decorate = compose(
const Actions = ({
context,
name,
label,
options,
value,
}) => (
<div className="actions">

View File

@ -4,8 +4,6 @@ import React from 'react';
import propertyPropTypes from './property-prop-types';
const Bool = ({
name,
label,
value,
}) => (
<select value={value}>

View File

@ -27,9 +27,6 @@ const decorate = compose(
const Condition = ({
context,
name,
label,
options,
value,
}) => (
<span className="condition">

View File

@ -4,8 +4,6 @@ import React from 'react';
import propertyPropTypes from './property-prop-types';
const Number = ({
name,
label,
options,
value,
}) => (
@ -13,13 +11,13 @@ const Number = ({
{
options
? (
<select name={name} value={value}>
<select value={value}>
{Object.entries(options).map(([optionValue, optionLabel]) => (
<option value={optionValue}>{optionLabel}</option>
))}
</select>
)
: <input name={name} type="text" value={value} />
: <input type="text" value={value} />
}
</span>
);

View File

@ -1,7 +1,5 @@
import PropTypes from 'prop-types';
export default {
name: PropTypes.string.isRequired,
label: PropTypes.string,
options: PropTypes.shape({}),
};

View File

@ -13,9 +13,6 @@ const decorate = compose(
const Routines = ({
context,
name,
label,
options,
value,
}) => {
const entries = Object.entries(value.routines);
@ -25,7 +22,7 @@ const Routines = ({
{
entries.length > 0 && (
entries.map(
([name, routine]) => (
([, routine]) => (
<li className="routine">
<Actions.component context={context} value={routine.routine} />
</li>

View File

@ -4,8 +4,6 @@ import React from 'react';
import propertyPropTypes from './property-prop-types';
const String = ({
name,
label,
options,
value,
}) => (
@ -13,13 +11,13 @@ const String = ({
{
options
? (
<select name={name} value={value}>
<select value={value}>
{Object.entries(options).map(([optionValue, optionLabel]) => (
<option value={optionValue}>{optionLabel}</option>
))}
</select>
)
: <input name={name} type="text" value={value} />
: <input type="text" value={value} />
}
</span>
);

View File

@ -5,8 +5,10 @@ import PropTypes from 'prop-types';
import React from 'react';
import Bool from './bool.type-renderer';
import Number from './number.type-renderer';
import propertyPropTypes from './property-prop-types';
import Steps from './steps';
import String from './string.type-renderer';
import {contextStepsList} from './steps-lists';
import {typeFits, typeFromSteps} from './typing';
@ -40,8 +42,9 @@ const renderValue = (context, type, value) => {
case 'bool':
return <Bool.component value={value.value} />;
case 'number':
return <Number.component value={value.value} />;
case 'string':
return <span className="wrapper"><input value={value.value} /></span>;
return <String.component value={value.value} />;
case 'object':
return (
<div className="object">