2022-06-06 11:32:28 -05:00
|
|
|
import { useTranslation } from 'next-i18next'
|
2022-06-17 12:02:09 +02:00
|
|
|
import { formatMm, formatPercentage} from 'shared/utils'
|
2022-06-06 11:32:28 -05:00
|
|
|
|
|
|
|
export const values = {
|
|
|
|
pct: props => {
|
|
|
|
const val = (typeof props.gist?.options?.[props.option] === 'undefined')
|
2022-06-17 12:02:09 +02:00
|
|
|
? props.design.config.options[props.option].pct/100
|
2022-06-06 11:32:28 -05:00
|
|
|
: props.gist.options[props.option]
|
|
|
|
return (
|
|
|
|
<span className={
|
2022-06-17 12:02:09 +02:00
|
|
|
val=== props.design.config.options[props.option].pct/100
|
2022-06-06 11:32:28 -05:00
|
|
|
? 'text-secondary-focus'
|
|
|
|
: 'text-accent'
|
|
|
|
}>
|
|
|
|
{formatPercentage(val)}
|
2022-07-05 18:37:29 -05:00
|
|
|
{props.design.config.options[props.option]?.toAbs && props.gist.measurements
|
2022-06-17 12:02:09 +02:00
|
|
|
? ' | ' +formatMm(props.design.config.options[props.option]?.toAbs(val, props.gist))
|
2022-06-06 11:32:28 -05:00
|
|
|
: null
|
|
|
|
}
|
|
|
|
</span>
|
|
|
|
)
|
|
|
|
},
|
|
|
|
bool: props => {
|
|
|
|
const { t } = useTranslation(['app'])
|
2022-06-17 12:02:09 +02:00
|
|
|
const dflt = props.design.config.options[props.option].bool
|
2022-06-06 11:32:28 -05:00
|
|
|
let current = props.gist?.options?.[props.option]
|
|
|
|
current = current === undefined ? dflt : current;
|
|
|
|
return (
|
|
|
|
<span className={
|
|
|
|
(dflt==current || typeof current === 'undefined')
|
|
|
|
? 'text-secondary-focus'
|
|
|
|
: 'text-accent'
|
|
|
|
}>
|
|
|
|
{current
|
|
|
|
? t('yes')
|
|
|
|
: t('no')
|
|
|
|
}
|
|
|
|
</span>
|
|
|
|
)
|
|
|
|
},
|
|
|
|
count: props => {
|
2022-06-17 12:02:09 +02:00
|
|
|
const dflt = props.design.config.options[props.option].count
|
2022-06-06 11:32:28 -05:00
|
|
|
const current = props.gist?.options?.[props.option]
|
|
|
|
return (dflt==current || typeof current === 'undefined')
|
|
|
|
? (<span className="text-secondary-focus">{dflt}</span>)
|
|
|
|
: (<span className="text-accent">{current}</span>)
|
|
|
|
},
|
|
|
|
list: props => {
|
2022-06-17 12:02:09 +02:00
|
|
|
const dflt = props.design.config.options[props.option].dflt
|
2022-06-06 11:32:28 -05:00
|
|
|
const current = props.gist?.options?.[props.option]
|
|
|
|
const prefix = `${props.option}.o.`
|
|
|
|
return (dflt==current || typeof current === 'undefined')
|
|
|
|
? (<span className="text-secondary-focus">{props.t(prefix+dflt)}</span>)
|
|
|
|
: (<span className="text-accent">{props.t(prefix+current)}</span>)
|
|
|
|
},
|
|
|
|
deg: props => {
|
2022-06-17 12:02:09 +02:00
|
|
|
const dflt = props.design.config.options[props.option].deg
|
2022-06-06 11:32:28 -05:00
|
|
|
const current = props.gist?.options?.[props.option]
|
|
|
|
return (dflt==current || typeof current === 'undefined')
|
|
|
|
? (<span className="text-secondary-focus">{dflt}°</span>)
|
|
|
|
: (<span className="text-accent">{current}°</span>)
|
|
|
|
},
|
|
|
|
mm: props => {
|
|
|
|
return (<p>No mm val yet</p>)
|
|
|
|
},
|
|
|
|
constant: props => {
|
|
|
|
return (<p>No constant val yet</p>)
|
|
|
|
}
|
|
|
|
}
|