1
0
Fork 0
freesewing/sites/shared/components/workbench/views/test/index.mjs

76 lines
1.8 KiB
JavaScript
Raw Normal View History

2023-06-06 14:43:23 -05:00
import { useTranslation } from 'next-i18next'
2023-06-06 13:18:44 -05:00
import { PanZoomPattern } from 'shared/components/workbench/pan-zoom-pattern.mjs'
import { TestMenu, ns as menuNs } from './menu.mjs'
import { PatternWithMenu, ns as wrapperNs } from '../pattern-with-menu.mjs'
2023-06-06 13:18:44 -05:00
export const ns = [...menuNs, wrapperNs]
2023-06-06 13:18:44 -05:00
export const TestView = ({
design,
pattern,
settings,
setSettings,
2023-06-06 13:18:44 -05:00
ui,
update,
language,
account,
DynamicDocs,
}) => {
2023-06-06 14:43:23 -05:00
const { t } = useTranslation(ns)
2023-06-06 13:18:44 -05:00
if (!pattern) return null
if (settings.sample) pattern.sample()
else pattern.draft()
const renderProps = pattern.getRenderProps()
const patternConfig = pattern.getConfig()
2023-06-06 14:43:23 -05:00
/*
* Translation of the title needs some work
*/
let title = t('workbench:testDesignOption', {
design,
option: t(`${design}:${settings.sample?.option}.t`),
})
if (settings.sample?.type === 'measurement')
title = t('workbench:testDesignMeasurement', {
design,
measurement: t(`measurements:${settings.sample?.measurement}`),
})
else if (settings.sample?.type === 'sets')
title = t('workbench:testDesignSets', {
design,
thing: 'fixme views/test/index.mjs',
})
2023-06-06 13:18:44 -05:00
return (
<PatternWithMenu
{...{
settings,
ui,
update,
control: account.control,
setSettings,
title: <h2>{title}</h2>,
pattern: <PanZoomPattern {...{ renderProps }} />,
menu: (
<TestMenu
{...{
design,
pattern,
patternConfig,
settings,
setSettings,
ui,
update,
language,
account,
DynamicDocs,
renderProps,
}}
/>
),
}}
/>
2023-06-06 13:18:44 -05:00
)
}