1
0
Fork 0
freesewing/sites/shared/components/workbench/layout/print/settings.js

114 lines
3.6 KiB
JavaScript
Raw Normal View History

2022-02-20 18:46:21 +01:00
import PageSizePicker from './pagesize-picker'
import OrientationPicker from './orientation-picker'
import PrintIcon from 'shared/components/icons/print'
import RightIcon from 'shared/components/icons/right'
import ClearIcon from 'shared/components/icons/clear'
import ExportIcon from 'shared/components/icons/export'
2022-06-28 02:02:51 -05:00
import { useTranslation } from 'next-i18next'
2022-02-20 18:46:21 +01:00
2022-11-14 14:02:11 -06:00
const PrintLayoutSettings = (props) => {
let pages = props.draft?.setStores[0].get('pages')
if (!pages) return null
const { cols, rows, count } = pages
2022-06-28 02:02:51 -05:00
const { t } = useTranslation(['workbench'])
2022-02-20 18:46:21 +01:00
const setMargin = (evt) => {
2022-11-14 14:02:11 -06:00
props.updateGist(
['_state', 'layout', 'forPrinting', 'page', 'margin'],
parseInt(evt.target.value)
)
}
2022-08-23 11:08:40 -05:00
const setCoverPage = () => {
2022-11-14 14:02:11 -06:00
props.updateGist(
['_state', 'layout', 'forPrinting', 'page', 'coverPage'],
!props.layoutSettings.coverPage
)
2022-08-23 11:08:40 -05:00
}
2022-02-20 18:46:21 +01:00
return (
2022-11-14 14:02:11 -06:00
<div>
<div
className="flex flex-row justify-between
mb-2"
>
<div className="flex gap-4">
<PageSizePicker {...props} />
<OrientationPicker {...props} />
</div>
<div className="flex gap-4">
<button
key="export"
onClick={props.exportIt}
2022-08-23 11:08:40 -05:00
className="btn btn-primary btn-outline"
disabled={count === 0}
2022-11-14 14:02:11 -06:00
aria-disabled={count === 0}
>
<ExportIcon className="h-6 w-6 mr-2" />
{t('export')}
</button>
<button
key="reset"
onClick={() => props.unsetGist(['layouts', 'printingLayout'])}
2022-11-14 14:02:11 -06:00
className="btn btn-primary btn-outline"
>
<ClearIcon className="h-6 w-6 mr-2" />
{t('reset')}
</button>
</div>
</div>
2022-08-23 11:08:40 -05:00
<div className="flex flex-row justify-between">
<div className="flex flex-row">
<label htmlFor="pageMargin" className="label mr-6">
<span className="mr-2">{t('pageMargin')}</span>
<input
type="range"
max={50}
min={0}
step={1}
onChange={setMargin}
value={props.layoutSettings.margin}
className="range range-sm mx-2"
name="pageMargin"
/>
<div className="text-center">
2022-11-14 14:02:11 -06:00
<span className="text-secondary">{props.layoutSettings.margin}mm</span>
2022-08-23 11:08:40 -05:00
</div>
<button
title={t('reset')}
className="btn btn-ghost btn-xs text-accent mx-2"
disabled={props.layoutSettings.margin == 10}
2022-11-14 14:02:11 -06:00
onClick={() => setMargin({ target: { value: 10 } })}
2022-08-23 11:08:40 -05:00
>
<ClearIcon />
</button>
</label>
<label htmlFor="coverPage" className="label">
<span className="mr-2">{t('coverPage')}</span>
2022-11-14 14:02:11 -06:00
<input
type="checkbox"
className="toggle toggle-primary"
checked={props.layoutSettings.coverPage}
onChange={setCoverPage}
/>
2022-08-23 11:08:40 -05:00
</label>
</div>
<div className="flex flex-row font-bold items-center px-0 text-xl">
<PrintIcon />
<span className="ml-2">{count}</span>
<span className="mx-6 opacity-50">|</span>
<RightIcon />
<span className="ml-2">{cols}</span>
<span className="mx-6 opacity-50">|</span>
2022-11-14 14:02:11 -06:00
<div className="rotate-90">
<RightIcon />
</div>
<span className="text-xl ml-2">{rows}</span>
</div>
</div>
2022-02-20 18:46:21 +01:00
</div>
)
}
export default PrintLayoutSettings