2023-05-11 19:14:48 +02:00
|
|
|
import { formatMm, formatPercentage } from 'shared/utils.mjs'
|
2023-05-29 13:35:04 -05:00
|
|
|
import { ListValue, HighlightedValue, PlainValue } from '../shared/values'
|
2023-05-29 23:22:26 -05:00
|
|
|
export const PctOptionValue = ({ config, current, settings, changed }) => {
|
2023-05-29 22:34:33 -05:00
|
|
|
const val = changed ? current : config.pct / 100
|
2023-05-11 19:14:48 +02:00
|
|
|
|
|
|
|
return (
|
2023-05-29 13:35:04 -05:00
|
|
|
<HighlightedValue changed={changed}>
|
2023-05-11 19:14:48 +02:00
|
|
|
{formatPercentage(val)}
|
2023-05-19 18:27:36 +02:00
|
|
|
{config.toAbs && settings.measurements ? ` | ${formatMm(config.toAbs(val, settings))}` : null}
|
2023-05-29 13:35:04 -05:00
|
|
|
</HighlightedValue>
|
2023-05-11 19:14:48 +02:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2023-05-29 23:22:26 -05:00
|
|
|
export const BoolOptionValue = ({ config, current, t, changed }) => (
|
2023-05-29 13:35:04 -05:00
|
|
|
<ListValue
|
|
|
|
{...{
|
|
|
|
current: current === undefined ? current : Number(current),
|
|
|
|
t,
|
|
|
|
config: { ...config, dflt: Number(config.bool) },
|
|
|
|
changed,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
2023-05-11 19:14:48 +02:00
|
|
|
|
2023-05-29 13:35:04 -05:00
|
|
|
export const CountOptionValue = ({ config, current, changed }) => (
|
2023-05-29 22:34:33 -05:00
|
|
|
<PlainValue {...{ current, changed, dflt: config.count }} />
|
2023-05-29 13:35:04 -05:00
|
|
|
)
|
2023-05-11 19:14:48 +02:00
|
|
|
|
2023-05-29 13:35:04 -05:00
|
|
|
export const ListOptionValue = ({ name, config, current, t, changed }) => {
|
2023-05-18 14:06:22 +02:00
|
|
|
const translate = config.doNotTranslate ? (input) => input : (input) => t(`${name}.o.${input}`)
|
2023-05-29 13:35:04 -05:00
|
|
|
const value = translate(changed ? current : config.dflt)
|
|
|
|
return <HighlightedValue changed={changed}> {value} </HighlightedValue>
|
2023-05-11 19:14:48 +02:00
|
|
|
}
|
|
|
|
|
2023-05-29 13:35:04 -05:00
|
|
|
export const DegOptionValue = ({ config, current, changed }) => (
|
|
|
|
<HighlightedValue changed={changed}> {changed ? current : config.deg}°</HighlightedValue>
|
|
|
|
)
|
2023-05-11 19:14:48 +02:00
|
|
|
|
|
|
|
export const MmOptionValue = () => (
|
|
|
|
<span className="text-error">FIXME: No MmOptionvalue implemented</span>
|
|
|
|
)
|
|
|
|
export const ConstantOptionValue = () => (
|
|
|
|
<span className="text-error">FIXME: No ConstantOptionvalue implemented</span>
|
|
|
|
)
|