2022-02-20 19:02:25 +01:00
|
|
|
import { useEffect } from 'react'
|
2022-02-20 18:46:21 +01:00
|
|
|
import { useTranslation } from 'next-i18next'
|
|
|
|
import Settings from './settings'
|
2022-06-28 13:41:27 -05:00
|
|
|
import Draft from '../draft/index'
|
2022-02-20 18:46:21 +01:00
|
|
|
import pluginBuilder from './plugin'
|
|
|
|
|
|
|
|
const PrintLayout = props => {
|
2022-02-20 19:02:25 +01:00
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (props.gist?._state?.xray?.enabled) props.updateGist(
|
|
|
|
['_state', 'xray', 'enabled'],
|
|
|
|
false
|
|
|
|
)
|
|
|
|
}, [])
|
|
|
|
|
2022-02-20 18:46:21 +01:00
|
|
|
const { t } = useTranslation(['workbench'])
|
|
|
|
|
2022-06-17 12:02:09 +02:00
|
|
|
const draft = new props.design(props.gist).use(pluginBuilder(
|
2022-02-20 18:46:21 +01:00
|
|
|
props.gist?._state?.layout?.forPrinting?.page?.size,
|
|
|
|
props.gist?._state?.layout?.forPrinting?.page?.orientation,
|
|
|
|
))
|
|
|
|
let patternProps
|
|
|
|
try {
|
|
|
|
draft.draft()
|
|
|
|
patternProps = draft.getRenderProps()
|
|
|
|
} catch(err) {
|
2022-03-06 18:54:30 +01:00
|
|
|
console.log(err, props.gist)
|
2022-02-20 18:46:21 +01:00
|
|
|
}
|
|
|
|
const bgProps = { fill: "url(#page)" }
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<h2 className="capitalize">
|
|
|
|
{
|
2022-06-17 12:02:09 +02:00
|
|
|
t('layoutThing', { thing: props.design.config.name })
|
2022-02-20 18:46:21 +01:00
|
|
|
+ ': '
|
|
|
|
+ t('forPrinting')
|
|
|
|
}
|
|
|
|
</h2>
|
|
|
|
<div className="m-4">
|
2022-02-20 19:29:14 +01:00
|
|
|
<Settings {...props} draft={draft}/>
|
2022-02-20 18:46:21 +01:00
|
|
|
</div>
|
|
|
|
<Draft
|
|
|
|
draft={draft}
|
|
|
|
gist={props.gist}
|
2022-02-25 08:30:03 +01:00
|
|
|
updateGist={props.updateGist}
|
2022-02-20 18:46:21 +01:00
|
|
|
patternProps={patternProps}
|
|
|
|
bgProps={bgProps}
|
2022-06-28 02:02:51 -05:00
|
|
|
gistReady={props.gistReady}
|
2022-02-20 18:46:21 +01:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default PrintLayout
|