1
0
Fork 0
freesewing/sites/shared/components/workbench/views/print/settings.mjs

66 lines
1.8 KiB
JavaScript
Raw Normal View History

2023-09-29 16:01:27 +02:00
// __SDEFILE__ - This file is a dependency for the stand-alone environment
2023-06-04 09:59:47 -05:00
import { PrintIcon } from 'shared/components/icons.mjs'
import { WorkbenchMenu } from 'shared/components/workbench/menus/shared/index.mjs'
import { ListInput, BoolInput, MmInput } from 'shared/components/workbench/menus/shared/inputs.mjs'
import {
BoolValue,
MmValue,
HighlightedValue,
} from 'shared/components/workbench/menus/shared/values.mjs'
import { loadPrintConfig, printSettingsPath } from './config.mjs'
import { capitalize } from 'shared/utils.mjs'
2023-06-04 09:59:47 -05:00
import get from 'lodash.get'
import { PatternIcon } from 'shared/components/icons.mjs'
2023-06-04 09:59:47 -05:00
const inputs = {
size: ListInput,
orientation: ListInput,
margin: MmInput,
coverPage: BoolInput,
cutlist: BoolInput,
}
const values = {
size: ({ current, changed, config }) => (
<HighlightedValue changed={changed}>
{capitalize(current ? current : config.dflt)}
</HighlightedValue>
),
orientation: ({ current, changed }) => (
<HighlightedValue changed={changed}>
<PatternIcon
className={`w-6 h-6 text-inherit ${current === 'landscape' ? '-rotate-90' : ''}`}
/>
</HighlightedValue>
),
2023-06-04 09:59:47 -05:00
margin: MmValue,
coverPage: BoolValue,
cutlist: BoolValue,
}
export const ns = ['print']
export const PrintSettings = ({ update, settings, ui, account }) => {
const config = loadPrintConfig(settings.units)
const passProps = { units: settings.units }
2023-06-06 11:17:14 -05:00
const updateFunc = (path, newVal) => update.ui([...printSettingsPath, ...path], newVal)
2023-06-04 09:59:47 -05:00
return (
<WorkbenchMenu
{...{
config,
control: account.control,
currentValues: get(ui, printSettingsPath, {}),
2023-06-04 09:59:47 -05:00
Icon: PrintIcon,
inputs,
values,
name: 'printSettings',
ns,
passProps,
updateFunc,
2023-06-21 16:07:30 -05:00
isFirst: true,
2023-06-04 09:59:47 -05:00
}}
/>
)
}