1
0
Fork 0
freesewing/sites/shared/components/workbench/menus/design-options/values.mjs
2023-06-02 12:39:55 -05:00

42 lines
1.5 KiB
JavaScript

import { formatMm, formatPercentage } from 'shared/utils.mjs'
import { ListValue, HighlightedValue, PlainValue, BoolValue } from '../shared/values'
/** Displays the current percentatge value, and the absolute value if configured */
export const PctOptionValue = ({ config, current, settings, changed }) => {
const val = changed ? current : config.pct / 100
return (
<HighlightedValue changed={changed}>
{formatPercentage(val)}
{config.toAbs && settings.measurements ? ` | ${formatMm(config.toAbs(val, settings))}` : null}
</HighlightedValue>
)
}
/** Displays a boolean value */
export const BoolOptionValue = BoolValue
/** Displays a count value*/
export const CountOptionValue = ({ config, current, changed }) => (
<PlainValue {...{ current, changed, dflt: config.count }} />
)
/** Displays a list option value */
export const ListOptionValue = (props) => (
<ListValue {...props} t={(input) => props.t(`${props.name}.o.${input}`)} />
)
/** Displays a degree value */
export const DegOptionValue = ({ config, current, changed }) => (
<HighlightedValue changed={changed}> {changed ? current : config.deg}&deg;</HighlightedValue>
)
/** Displays the MmOptions are not supported */
export const MmOptionValue = () => (
<span className="text-error">FIXME: No Mm Options are not supported</span>
)
/** Displays that constant values are not implemented in the front end */
export const ConstantOptionValue = () => (
<span className="text-error">FIXME: No ConstantOptionvalue implemented</span>
)