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 = { pct: props => { const val = (typeof props.gist?.options?.[props.option] === 'undefined') ? props.pattern.config.options[props.option].pct/100 : props.gist.options[props.option] return ( {formatPercentage(val)} {props.pattern.config.options[props.option]?.toAbs ? ' | ' +formatMm(props.pattern.config.options[props.option]?.toAbs(val, props.gist)) : null } ) }, bool: props => { const dflt = props.pattern.config.options[props.option].bool const current = props.gist?.options?.[props.option] return ( {props.gist?.options?.[props.option] ? props.app.t('app.yes') : props.app.t('app.no') } ) }, count: props => { 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

}, list: props => { return

No val yet

}, mm: props => { return

No val yet

}, constant: props => { return

No val yet

}, } const Tmp = props =>

not yet

const inputs = { pct: PercentOption, count: CountOption, deg: Tmp, list: ListOption, mm: Tmp, constant: Tmp, } const Option = props => { const type = optionType(props.pattern.config.options[props.option]) const Input = inputs[type] const Value = values[type] const toggleBoolean = () => { const dflt = props.pattern.config.options[props.option].bool const current = props.gist?.options?.[props.option] if (typeof current === 'undefined') props.updateGist(['options', props.option], !dflt) else props.unsetGist(['options', props.option]) } if (type === 'bool') return (
  • ) return (
  • <>° { props.app.t(`options.${props.pattern.config.name}.${props.option}.title`) }
  • ) } export default Option