1
0
Fork 0
freesewing/sites/shared/components/workbench/menus/design-options/values.mjs

45 lines
1.5 KiB
JavaScript
Raw Normal View History

2023-05-11 19:14:48 +02:00
import { formatMm, formatPercentage } from 'shared/utils.mjs'
import { ListValue, HighlightedValue, PlainValue } from '../shared/values'
2023-05-29 23:22:26 -05:00
export const PctOptionValue = ({ config, current, settings, changed }) => {
const val = changed ? current : config.pct / 100
2023-05-11 19:14:48 +02:00
return (
<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}
</HighlightedValue>
2023-05-11 19:14:48 +02:00
)
}
2023-05-29 23:22:26 -05:00
export const BoolOptionValue = ({ config, current, t, changed }) => (
<ListValue
{...{
current: current === undefined ? current : Number(current),
t,
config: { ...config, dflt: Number(config.bool) },
changed,
}}
/>
)
2023-05-11 19:14:48 +02:00
export const CountOptionValue = ({ config, current, changed }) => (
<PlainValue {...{ current, changed, dflt: config.count }} />
)
2023-05-11 19:14:48 +02:00
export const ListOptionValue = ({ name, config, current, t, changed }) => {
const translate = config.doNotTranslate ? (input) => input : (input) => t(`${name}.o.${input}`)
const value = translate(changed ? current : config.dflt)
return <HighlightedValue changed={changed}> {value} </HighlightedValue>
2023-05-11 19:14:48 +02:00
}
export const DegOptionValue = ({ config, current, changed }) => (
<HighlightedValue changed={changed}> {changed ? current : config.deg}&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>
)