1
0
Fork 0
freesewing/sites/shared/components/workbench/sample.js

35 lines
760 B
JavaScript
Raw Normal View History

2022-02-13 15:45:27 +01:00
import svgattrPlugin from '@freesewing/plugin-svgattr'
import { useTranslation } from 'next-i18next'
const LabSample = ({ gist, draft }) => {
const { t } = useTranslation(['workbench'])
let svg
let title = ''
if (gist.sample) {
try {
draft.use(svgattrPlugin, {
2022-02-19 17:01:28 +01:00
class: 'freesewing pattern max-h-screen'
2022-02-13 15:45:27 +01:00
})
draft.sample()
svg = draft.render()
}
catch(err) {
console.log(err)
}
if (gist.sample.type === 'option') {
title = t('testThing', {
thing: ' : ' + t('option') + ' : ' + gist.sample.option
})
}
}
return (
<>
<h2>{title}</h2>
2022-02-19 17:01:28 +01:00
<div className="freesewing pattern" dangerouslySetInnerHTML={{__html: svg}} />
2022-02-13 15:45:27 +01:00
</>
)
}
export default LabSample