refactor: no onIncrement
This commit is contained in:
parent
c67a1b23ac
commit
562512e2b9
|
@ -6,7 +6,7 @@ import propTypes from './prop-types';
|
|||
const Bool = ({
|
||||
dispatchers: {
|
||||
onChange = () => {},
|
||||
},
|
||||
} = {},
|
||||
value,
|
||||
}) => (
|
||||
<select onChange={(event) => onChange(!!event.target.value, event)} value={value ? '1' : ''}>
|
||||
|
|
|
@ -49,11 +49,6 @@ const Condition = ({
|
|||
: {operands: mergeToOperand(index, newValue)},
|
||||
);
|
||||
},
|
||||
onIncrement: (operandValue) => {
|
||||
onChange({
|
||||
operands: mergeToOperand(index, operands[index].value + operandValue),
|
||||
});
|
||||
},
|
||||
});
|
||||
return (
|
||||
<span className="condition">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {compose} from '@avocado/core';
|
||||
import contempo from 'contempo';
|
||||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
import React, {useRef} from 'react';
|
||||
|
||||
import propTypes from './prop-types';
|
||||
|
||||
|
@ -12,11 +12,12 @@ const decorate = compose(
|
|||
const Number = ({
|
||||
dispatchers: {
|
||||
onChange = () => {},
|
||||
onIncrement = () => {},
|
||||
},
|
||||
} = {},
|
||||
options,
|
||||
value,
|
||||
}) => (
|
||||
}) => {
|
||||
const inputRef = useRef(null);
|
||||
return (
|
||||
<span className="number">
|
||||
{
|
||||
options
|
||||
|
@ -38,18 +39,19 @@ const Number = ({
|
|||
}
|
||||
}}
|
||||
// onWheel={(e) => (e.preventDefault(), false)}
|
||||
ref={inputRef}
|
||||
type="text"
|
||||
value={value}
|
||||
/>
|
||||
<div className="controls">
|
||||
<button
|
||||
onClick={(event) => onIncrement(1, event)}
|
||||
onClick={(event) => onChange(1 + parseInt(inputRef.current.value, 10), event)}
|
||||
type="button"
|
||||
>
|
||||
+
|
||||
</button>
|
||||
<button
|
||||
onClick={(event) => onIncrement(-1, event)}
|
||||
onClick={(event) => onChange(-1 + parseInt(inputRef.current.value, 10), event)}
|
||||
type="button"
|
||||
>
|
||||
-
|
||||
|
@ -60,6 +62,7 @@ const Number = ({
|
|||
}
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
Number.propTypes = {
|
||||
...propTypes,
|
||||
|
|
|
@ -6,7 +6,7 @@ import propTypes from './prop-types';
|
|||
const String = ({
|
||||
dispatchers: {
|
||||
onChange = () => {},
|
||||
},
|
||||
} = {},
|
||||
options,
|
||||
value,
|
||||
}) => (
|
||||
|
|
|
@ -67,22 +67,6 @@ const slice = createSlice({
|
|||
name: 'entities',
|
||||
initialState: adapter.getInitialState({uris: {}}),
|
||||
reducers: {
|
||||
incrementTraitProperty: (state, {
|
||||
payload: {
|
||||
target,
|
||||
trait,
|
||||
half,
|
||||
key,
|
||||
value,
|
||||
},
|
||||
}) => {
|
||||
const {traits} = state.entities[target];
|
||||
traits[trait] = traits[trait] || {};
|
||||
traits[trait][half] = traits[trait][half] || {};
|
||||
traits[trait][half][key] = traits[trait][half][key] || 0;
|
||||
traits[trait][half][key] += parseFloat(value);
|
||||
state.entities[target].traits = traits;
|
||||
},
|
||||
setTraitProperty: (state, {
|
||||
payload: {
|
||||
target,
|
||||
|
@ -110,7 +94,6 @@ const slice = createSlice({
|
|||
});
|
||||
|
||||
export const {
|
||||
incrementTraitProperty,
|
||||
setTraitProperty,
|
||||
} = slice.actions;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import {useDispatch} from 'react-redux';
|
|||
|
||||
import Value from '~/client/value';
|
||||
|
||||
import {incrementTraitProperty, setTraitProperty} from './state';
|
||||
import {setTraitProperty} from './state';
|
||||
|
||||
let TraitComponents;
|
||||
const ensureTraitComponents = () => {
|
||||
|
@ -51,7 +51,6 @@ const makeTraitPaneRenderer = (context, dispatch, target, traitType) => (trait)
|
|||
context={context}
|
||||
dispatchers={{
|
||||
onChange: (value) => dispatch(setTraitProperty({...payload, value})),
|
||||
onIncrement: (value) => dispatch(incrementTraitProperty({...payload, value})),
|
||||
}}
|
||||
options={options}
|
||||
type={type}
|
||||
|
|
Loading…
Reference in New Issue
Block a user