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

43 lines
1.5 KiB
JavaScript
Raw Normal View History

2023-05-11 19:14:48 +02:00
import { formatMm, formatPercentage } from 'shared/utils.mjs'
2023-05-31 17:42:16 -05:00
import { ListValue, HighlightedValue, PlainValue, BoolValue } from '../shared/values'
/** Displays the current percentatge value, and the absolute value if configured */
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-31 17:42:16 -05:00
/** Displays a boolean value */
export const BoolOptionValue = BoolValue
2023-05-11 19:14:48 +02:00
2023-05-31 17:42:16 -05:00
/** Displays a count value*/
export const CountOptionValue = ({ config, current, changed }) => (
<PlainValue {...{ current, changed, dflt: config.count }} />
)
2023-05-11 19:14:48 +02:00
2023-05-31 17:42:16 -05:00
/** Displays a list option value */
export const ListOptionValue = (props) => (
<ListValue {...props} t={(input) => props.t(`${props.name}.o.${input}`)} />
)
2023-05-11 19:14:48 +02:00
2023-05-31 17:42:16 -05:00
/** Displays a degree value */
export const DegOptionValue = ({ config, current, changed }) => (
<HighlightedValue changed={changed}> {changed ? current : config.deg}&deg;</HighlightedValue>
)
2023-05-11 19:14:48 +02:00
2023-05-31 17:42:16 -05:00
/** Displays the MmOptions are not supported */
2023-05-11 19:14:48 +02:00
export const MmOptionValue = () => (
2023-05-31 17:42:16 -05:00
<span className="text-error">FIXME: No Mm Options are not supported</span>
2023-05-11 19:14:48 +02:00
)
2023-05-31 17:42:16 -05:00
/** Displays that constant values are not implemented in the front end */
2023-05-11 19:14:48 +02:00
export const ConstantOptionValue = () => (
<span className="text-error">FIXME: No ConstantOptionvalue implemented</span>
)