1
0
Fork 0
freesewing/sites/shared/components/workbench/layout/cut/index.mjs

55 lines
1.4 KiB
JavaScript
Raw Normal View History

2022-02-20 18:46:21 +01:00
import { useTranslation } from 'next-i18next'
2023-02-05 19:58:25 +01:00
import { CutLayoutSettings } from './settings.mjs'
import { Draft } from '../draft/index.mjs'
import { fabricPlugin } from '../layout-part-plugin.mjs'
import { useEffect } from 'react'
2022-02-20 18:46:21 +01:00
export const CutLayout = (props) => {
2022-02-20 18:46:21 +01:00
const { t } = useTranslation(['workbench'])
// disable xray
useEffect(() => {
if (props.gist?._state?.xray?.enabled) props.updateGist(['_state', 'xray', 'enabled'], false)
})
const draft = props.draft
// add the pages plugin to the draft
const layoutSettings = {
sheetWidth: 500,
sheetHeight: 1000,
...props.gist?._state?.layout?.forCutting?.fabric,
}
draft.use(fabricPlugin(layoutSettings))
let patternProps
try {
// draft the pattern
draft.draft()
patternProps = draft.getRenderProps()
} catch (err) {
console.log(err, props.gist)
}
const bgProps = { fill: 'url(#page)' }
let name = props.design.designConfig.data.name
name = name.replace('@freesewing/', '')
2022-02-20 18:46:21 +01:00
return (
<div>
<h2 className="capitalize">{t('layoutThing', { thing: name }) + ': ' + t('forCutting')}</h2>
2023-02-05 19:58:25 +01:00
<CutLayoutSettings {...props} />
<Draft
draft={draft}
gist={props.gist}
updateGist={props.updateGist}
patternProps={patternProps}
bgProps={bgProps}
gistReady={props.gistReady}
layoutPart="fabric"
layoutType="cuttingLayout"
/>
2022-02-20 18:46:21 +01:00
</div>
)
}