import { useTranslation } from 'next-i18next' import { formatMm, formatPercentage} from 'shared/utils' export const values = { pct: props => { const val = (typeof props.gist?.options?.[props.option] === 'undefined') ? props.design.config.options[props.option].pct/100 : props.gist.options[props.option] return ( {formatPercentage(val)} {props.design.config.options[props.option]?.toAbs && props.gist.measurements ? ' | ' +formatMm(props.design.config.options[props.option]?.toAbs(val, props.gist)) : null } ) }, bool: props => { const { t } = useTranslation(['app']) const dflt = props.design.config.options[props.option].bool let current = props.gist?.options?.[props.option] current = current === undefined ? dflt : current; return ( {current ? t('yes') : t('no') } ) }, count: props => { const dflt = props.design.config.options[props.option].count const current = props.gist?.options?.[props.option] return (dflt==current || typeof current === 'undefined') ? ({dflt}) : ({current}) }, list: props => { const dflt = props.design.config.options[props.option].dflt const current = props.gist?.options?.[props.option] const prefix = `${props.option}.o.` return (dflt==current || typeof current === 'undefined') ? ({props.t(prefix+dflt)}) : ({props.t(prefix+current)}) }, deg: props => { const dflt = props.design.config.options[props.option].deg const current = props.gist?.options?.[props.option] return (dflt==current || typeof current === 'undefined') ? ({dflt}°) : ({current}°) }, mm: props => { return (
No mm val yet
) }, constant: props => { return (No constant val yet
) } }