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

45 lines
1.2 KiB
JavaScript
Raw Normal View History

2023-06-02 09:41:00 -05:00
import { formatMm } from 'shared/utils.mjs'
import { mergeOptions } from '@freesewing/core'
2023-06-02 09:41:00 -05:00
import {
BoolInput,
ConstantInput,
SliderInput,
DegInput,
ListInput,
PctInput,
} from '../shared/inputs.mjs'
const PctOptionInput = (props) => {
const { config, settings, changed } = props
const currentOrDefault = changed ? props.current : config.dflt / 100
console.log(settings)
2023-06-02 09:41:00 -05:00
return (
<PctInput {...props}>
<div className="flex flex-row justify-around">
<span className={changed ? 'text-accent' : 'text-secondary'}>
{config.toAbs
? formatMm(
config.toAbs(
currentOrDefault,
settings,
mergeOptions(settings, props.patternConfig.options)
)
)
2023-06-02 09:41:00 -05:00
: ' '}
</span>
</div>
</PctInput>
)
}
// Facilitate lookup of the input component
export const inputs = {
bool: BoolInput,
constant: ConstantInput,
count: (props) => <SliderInput {...props} config={{ ...props.config, step: 1 }} />,
2023-06-02 09:41:00 -05:00
deg: DegInput,
list: (props) => <ListInput {...props} isDesignOption />,
2023-06-02 09:41:00 -05:00
mm: () => <span>FIXME: Mm options are deprecated. Please report this </span>,
pct: PctOptionInput,
}