import { useState } from 'react' import { ClearIcon, EditIcon } from 'shared/components/icons.mjs' import { formatMm, round } from 'shared/utils.mjs' import { useTranslation } from 'next-i18next' const EditOption = (props) => (
) export const DesignOptionPctDeg = (props) => { const { t } = useTranslation(['app']) const suffix = props.type === 'deg' ? '°' : '%' const factor = props.type === 'deg' ? 1 : 100 const { max, min } = props.design.patternConfig.options[props.option] const dflt = props.design.patternConfig.options[props.option][props.type || 'pct'] const val = typeof props.gist?.options?.[props.option] === 'undefined' ? dflt : props.gist.options[props.option] * factor const [value, setValue] = useState(val) const [editOption, setEditOption] = useState(false) const handleChange = (evt) => { const newVal = evt.target.value setValue(newVal) props.updateGist(['options', props.option], newVal / factor) } const reset = () => { setValue(dflt) props.unsetGist(['options', props.option]) } return (

{props.ot(`${props.option}.d`)}

{editOption ? ( ) : ( <> {round(min)} {suffix} {round(val)} {suffix} {round(max)} {suffix} )}
{props.design.patternConfig.options[props.option]?.toAbs && props.gist.measurements ? formatMm( props.design.patternConfig.options[props.option].toAbs(value / 100, props.gist) ) : ' '}
) }