chore: tidy
This commit is contained in:
parent
0c7974b885
commit
53c626b689
|
@ -19,11 +19,11 @@ const ensureTraitComponents = () => {
|
|||
}
|
||||
};
|
||||
|
||||
const makePane = (context, dispatch, target, type) => (trait) => {
|
||||
const makeTraitPaneRenderer = (context, dispatch, target, traitType) => (trait) => {
|
||||
ensureTraitComponents();
|
||||
const {params, state} = trait;
|
||||
const {[type]: TraitComponent} = TraitComponents;
|
||||
const Trait = lookupTrait(type);
|
||||
const {[traitType]: TraitComponent} = TraitComponents;
|
||||
const Trait = lookupTrait(traitType);
|
||||
if (!Trait) {
|
||||
return null;
|
||||
}
|
||||
|
@ -34,6 +34,12 @@ const makePane = (context, dispatch, target, type) => (trait) => {
|
|||
// eslint-disable-next-line no-shadow
|
||||
Object.values(mapObject(description, (description, key) => {
|
||||
const {label, options} = description;
|
||||
const payload = {
|
||||
target,
|
||||
trait: traitType,
|
||||
half,
|
||||
key,
|
||||
};
|
||||
return (
|
||||
<label key={key}>
|
||||
<span className="text">
|
||||
|
@ -44,20 +50,8 @@ const makePane = (context, dispatch, target, type) => (trait) => {
|
|||
<Value.Component
|
||||
context={context}
|
||||
dispatchers={{
|
||||
onChange: (value) => dispatch(setTraitProperty({
|
||||
target,
|
||||
trait: type,
|
||||
half,
|
||||
key,
|
||||
value,
|
||||
})),
|
||||
onIncrement: (value) => dispatch(incrementTraitProperty({
|
||||
target,
|
||||
trait: type,
|
||||
half,
|
||||
key,
|
||||
value,
|
||||
})),
|
||||
onChange: (value) => dispatch(setTraitProperty({...payload, value})),
|
||||
onIncrement: (value) => dispatch(incrementTraitProperty({...payload, value})),
|
||||
}}
|
||||
options={options}
|
||||
value={values[key]}
|
||||
|
@ -84,7 +78,7 @@ const TraitPane = (props) => {
|
|||
const dispatch = useDispatch();
|
||||
// TODO: dependency on context is too noisy
|
||||
const renderTraitPane = useMemo(
|
||||
() => makePane(context, dispatch, target, type),
|
||||
() => makeTraitPaneRenderer(context, dispatch, target, type),
|
||||
[context, dispatch, target, type],
|
||||
);
|
||||
return useMemo(
|
||||
|
|
Loading…
Reference in New Issue
Block a user