From a4db63f990a13364cc0b632f9c839477929a97a3 Mon Sep 17 00:00:00 2001 From: Joost De Cock Date: Wed, 26 Jan 2022 08:52:26 +0100 Subject: [PATCH] feat(lab): Allow manual edit of pct options --- .../components/icons/edit.js | 7 ++ .../inputs/design-option-percentage.js | 81 ++++++++++++++++--- packages/freesewing.shared/themes/light.js | 4 +- 3 files changed, 78 insertions(+), 14 deletions(-) create mode 100644 packages/freesewing.shared/components/icons/edit.js diff --git a/packages/freesewing.shared/components/icons/edit.js b/packages/freesewing.shared/components/icons/edit.js new file mode 100644 index 00000000000..5cd1f91869c --- /dev/null +++ b/packages/freesewing.shared/components/icons/edit.js @@ -0,0 +1,7 @@ +const EditIcon = () => ( + + + +) + +export default EditIcon diff --git a/packages/freesewing.shared/components/workbench/inputs/design-option-percentage.js b/packages/freesewing.shared/components/workbench/inputs/design-option-percentage.js index 66e11e5ac8b..991f429e247 100644 --- a/packages/freesewing.shared/components/workbench/inputs/design-option-percentage.js +++ b/packages/freesewing.shared/components/workbench/inputs/design-option-percentage.js @@ -1,7 +1,30 @@ 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 EditPercentage = props => ( +
+ + +
+) + + const DesignOptionPercentage = props => { const { pct, max, min } = props.pattern.config.options[props.option] const val = (typeof props.gist?.options?.[props.option] === 'undefined') @@ -9,6 +32,7 @@ const DesignOptionPercentage = props => { : props.gist.options[props.option] * 100 const [value, setValue] = useState(val) + const [editPercentage, setEditPercentage] = useState(false) const handleChange = (evt) => { const newVal = evt.target.value @@ -23,9 +47,27 @@ const DesignOptionPercentage = props => { return (
- {round(min)}% - {round(val)}% - {round(max)}% + {editPercentage + ? + : ( + <> + {round(min)}% + + {round(val)}% + + {round(max)}% + + ) + }
{ value={value} onChange={handleChange} className={` - range range-sm + range range-sm mt-1 ${val === pct ? 'range-secondary' : 'range-accent'} `} /> @@ -46,14 +88,29 @@ const DesignOptionPercentage = props => { : ' ' } - +
+ + +
) diff --git a/packages/freesewing.shared/themes/light.js b/packages/freesewing.shared/themes/light.js index 2eefa499c02..52c7c10b99c 100644 --- a/packages/freesewing.shared/themes/light.js +++ b/packages/freesewing.shared/themes/light.js @@ -42,12 +42,12 @@ module.exports = { // base-200: A slightly darker background color, used for hovers and so on 'base-200': colors.neutral['200'], // base-300: A shade midway between dark and light - 'base-300': colors.neutral['400'], + 'base-300': colors.neutral['500'], // base-content: The default text color for a regular page (docs and so on) 'base-content': colors.neutral['700'], // primary: The main brand color and color of the primary button - 'primary': colors.violet['700'], + 'primary': colors.violet['500'], // primary-focus: The :hover color for the primary button 'primary-focus': colors.violet['600'], // primary-content: The text color on a primary button