diff --git a/packages/freesewing.shared/components/workbench/inputs/design-option-count.js b/packages/freesewing.shared/components/workbench/inputs/design-option-count.js new file mode 100644 index 00000000000..bd4a8e4d9e7 --- /dev/null +++ b/packages/freesewing.shared/components/workbench/inputs/design-option-count.js @@ -0,0 +1,114 @@ +import { useState } from 'react' +import ClearIcon from 'shared/components/icons/clear.js' +import EditIcon from 'shared/components/icons/edit.js' +import { formatMm, round } from 'shared/utils.js' + +const EditCount = props => ( +
+ + +
+) + + +const DesignOptionCount = props => { + const { count, max, min } = props.pattern.config.options[props.option] + const val = (typeof props.gist?.options?.[props.option] === 'undefined') + ? count + : props.gist.options[props.option] + + const [value, setValue] = useState(val) + const [editCount, setEditCount] = useState(false) + + const handleChange = (evt) => { + const newVal = evt.target.value + setValue(newVal) + props.updateGist(['options', props.option], newVal) + } + const reset = () => { + setValue(count) + props.unsetGist(['options', props.option]) + } + + return ( +
+
+ {editCount + ? + : ( + <> + {min} + + {val} + + {max} + + ) + } +
+ +
+ +
+ + +
+
+
+ ) +} + +export default DesignOptionCount diff --git a/packages/freesewing.shared/components/workbench/menu/design-options/option.js b/packages/freesewing.shared/components/workbench/menu/design-options/option.js index a58d7d96705..e0d749e6bd4 100644 --- a/packages/freesewing.shared/components/workbench/menu/design-options/option.js +++ b/packages/freesewing.shared/components/workbench/menu/design-options/option.js @@ -1,5 +1,7 @@ import { linkClasses, Chevron } from 'shared/components/navigation/primary.js' import PercentOption from 'shared/components/workbench/inputs/design-option-percentage' +import CountOption from 'shared/components/workbench/inputs/design-option-count' +import ListOption from 'shared/components/workbench/inputs/design-option-list' import { formatMm, formatPercentage, optionType } from 'shared/utils.js' const values = { @@ -38,7 +40,11 @@ const values = { ) }, count: props => { - return

No val yet

+ const dflt = props.pattern.config.options[props.option].count + const current = props.gist?.options?.[props.option] + return (dflt==current || typeof current === 'undefined') + ? {dflt} + : {current} }, deg: props => { return

No val yet

@@ -58,10 +64,9 @@ const Tmp = props =>

not yet

const inputs = { pct: PercentOption, - bool: Tmp, - count: Tmp, + count: CountOption, deg: Tmp, - list: Tmp, + list: ListOption, mm: Tmp, constant: Tmp, } @@ -78,7 +83,6 @@ const Option = props => { if (typeof current === 'undefined') props.updateGist(['options', props.option], !dflt) else props.unsetGist(['options', props.option]) - } if (type === 'bool') return (