2023-09-29 16:01:27 +02:00
|
|
|
// __SDEFILE__ - This file is a dependency for the stand-alone environment
|
2023-10-04 20:31:40 +02:00
|
|
|
import { controlLevels } from 'shared/config/freesewing.config.mjs'
|
2023-05-08 19:28:03 +02:00
|
|
|
// Hooks
|
2023-06-15 18:53:45 +02:00
|
|
|
import { useState } from 'react'
|
2023-05-08 19:28:03 +02:00
|
|
|
import { useTranslation } from 'next-i18next'
|
|
|
|
// Components
|
|
|
|
import {
|
|
|
|
BeakerIcon,
|
|
|
|
CodeIcon,
|
|
|
|
CutIcon,
|
|
|
|
OptionsIcon,
|
|
|
|
PrintIcon,
|
2023-09-27 12:04:26 +02:00
|
|
|
SaveIcon,
|
|
|
|
SaveAsIcon,
|
2023-06-12 19:38:20 +02:00
|
|
|
RightIcon,
|
|
|
|
LeftIcon,
|
|
|
|
DocsIcon,
|
2023-06-15 18:33:30 +02:00
|
|
|
MeasieIcon,
|
2023-08-27 16:24:18 +02:00
|
|
|
XrayIcon,
|
|
|
|
EditIcon,
|
|
|
|
ExportIcon,
|
2023-05-08 19:28:03 +02:00
|
|
|
} from 'shared/components/icons.mjs'
|
2023-06-12 19:38:20 +02:00
|
|
|
import Link from 'next/link'
|
2023-06-24 16:49:28 -05:00
|
|
|
import { MenuWrapper } from 'shared/components/workbench/menus/shared/menu-wrapper.mjs'
|
2023-05-08 19:28:03 +02:00
|
|
|
|
|
|
|
export const ns = ['workbench', 'sections']
|
|
|
|
|
2023-06-24 17:26:09 -05:00
|
|
|
const icons = {
|
|
|
|
test: BeakerIcon,
|
2023-08-27 16:24:18 +02:00
|
|
|
export: ExportIcon,
|
|
|
|
Edit: EditIcon,
|
2023-06-24 17:26:09 -05:00
|
|
|
cut: CutIcon,
|
|
|
|
draft: OptionsIcon,
|
|
|
|
print: PrintIcon,
|
2023-09-27 12:04:26 +02:00
|
|
|
save: SaveIcon,
|
|
|
|
saveas: SaveAsIcon,
|
2023-08-27 16:24:18 +02:00
|
|
|
logs: CodeIcon,
|
|
|
|
inspect: XrayIcon,
|
2023-06-24 17:26:09 -05:00
|
|
|
measies: MeasieIcon,
|
|
|
|
}
|
|
|
|
|
2023-06-12 19:38:20 +02:00
|
|
|
export const NavButton = ({
|
|
|
|
href,
|
|
|
|
label,
|
|
|
|
children,
|
|
|
|
onClick = false,
|
|
|
|
active = false,
|
2023-10-04 20:31:40 +02:00
|
|
|
extraClasses = 'lg:hover:bg-secondary lg:hover:text-secondary-content',
|
2023-06-12 19:38:20 +02:00
|
|
|
}) => {
|
|
|
|
const className = `w-full flex flex-row items-center px-4 py-2 ${extraClasses} ${
|
2023-10-04 20:31:40 +02:00
|
|
|
active
|
|
|
|
? 'font-bold lg:font-normal bg-secondary bg-opacity-10 lg:bg-secondary lg:text-secondary-content lg:bg-opacity-50'
|
|
|
|
: 'lg:bg-neutral lg:text-neutral-content'
|
2023-06-12 19:38:20 +02:00
|
|
|
}`
|
2023-10-04 20:31:40 +02:00
|
|
|
const span = <span className="block grow text-left">{label}</span>
|
2023-06-12 19:38:20 +02:00
|
|
|
|
|
|
|
return onClick ? (
|
|
|
|
<button {...{ onClick, className }} title={label}>
|
|
|
|
{span}
|
|
|
|
{children}
|
|
|
|
</button>
|
|
|
|
) : (
|
|
|
|
<Link {...{ href, className }} title={label}>
|
|
|
|
{span}
|
|
|
|
{children}
|
|
|
|
</Link>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2023-10-04 20:31:40 +02:00
|
|
|
const NavIcons = ({ setView, setDense, dense, view, saveAs = false, control }) => {
|
2023-05-08 19:28:03 +02:00
|
|
|
const { t } = useTranslation(['header'])
|
2023-06-12 19:38:20 +02:00
|
|
|
const iconSize = 'h-6 w-6 grow-0'
|
2023-05-08 19:28:03 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<NavButton
|
2023-06-12 19:38:20 +02:00
|
|
|
onClick={() => setDense(!dense)}
|
2023-10-04 20:31:40 +02:00
|
|
|
label=""
|
2023-08-30 10:44:35 +02:00
|
|
|
extraClasses="hidden lg:flex text-accent bg-neutral hover:bg-accent hover:text-neutral-content"
|
2023-05-08 19:28:03 +02:00
|
|
|
>
|
2023-06-12 19:38:20 +02:00
|
|
|
{dense ? (
|
2023-06-20 17:18:01 -05:00
|
|
|
<RightIcon
|
|
|
|
className={`${iconSize} group-hover:animate-[bounceright_1s_infinite] animate-[bounceright_1s_5]`}
|
|
|
|
stroke={4}
|
|
|
|
/>
|
2023-06-12 19:38:20 +02:00
|
|
|
) : (
|
|
|
|
<LeftIcon className={`${iconSize} animate-bounce-right`} stroke={4} />
|
|
|
|
)}
|
2023-05-08 19:28:03 +02:00
|
|
|
</NavButton>
|
2023-10-04 20:31:40 +02:00
|
|
|
{control >= controlLevels.views.draft && (
|
|
|
|
<NavButton
|
|
|
|
onClick={() => setView('draft')}
|
|
|
|
label={t('workbench:patternEditor')}
|
|
|
|
active={view === 'draft'}
|
|
|
|
>
|
|
|
|
<OptionsIcon className={iconSize} />
|
|
|
|
</NavButton>
|
|
|
|
)}
|
|
|
|
{control >= controlLevels.views.measies && (
|
|
|
|
<NavButton
|
|
|
|
onClick={() => setView('measies')}
|
|
|
|
label={t('workbench:measies')}
|
|
|
|
active={view === 'measies'}
|
|
|
|
>
|
|
|
|
<MeasieIcon className={iconSize} />
|
|
|
|
</NavButton>
|
|
|
|
)}
|
|
|
|
{control >= controlLevels.views.test && (
|
|
|
|
<NavButton
|
|
|
|
onClick={() => setView('test')}
|
2023-11-03 19:41:21 +01:00
|
|
|
label={t('workbench:testDesign')}
|
2023-10-04 20:31:40 +02:00
|
|
|
active={view === 'test'}
|
|
|
|
>
|
|
|
|
<BeakerIcon className={iconSize} />
|
|
|
|
</NavButton>
|
|
|
|
)}
|
|
|
|
{control >= controlLevels.views.print && (
|
|
|
|
<NavButton
|
|
|
|
onClick={() => setView('print')}
|
|
|
|
label={t('workbench:printLayout')}
|
|
|
|
active={view === 'print'}
|
|
|
|
>
|
|
|
|
<PrintIcon className={iconSize} />
|
|
|
|
</NavButton>
|
|
|
|
)}
|
2023-09-26 15:49:03 +02:00
|
|
|
{/*!isProduction && (
|
2023-08-30 17:43:27 +02:00
|
|
|
<NavButton
|
|
|
|
onClick={() => setView('cut')}
|
|
|
|
label={t('workbench:cutLayout')}
|
|
|
|
active={view === 'cut'}
|
|
|
|
>
|
|
|
|
<CutIcon className={iconSize} />
|
|
|
|
</NavButton>
|
2023-09-26 15:49:03 +02:00
|
|
|
)*/}
|
2023-10-04 20:31:40 +02:00
|
|
|
{control >= controlLevels.views.save && (
|
|
|
|
<NavButton
|
|
|
|
onClick={() => setView('save')}
|
|
|
|
label={t(`workbench:${saveAs ? 'savePattern' : 'savePatternAsHellip'}`)}
|
|
|
|
active={view === 'save'}
|
|
|
|
>
|
|
|
|
{saveAs ? <SaveIcon className={iconSize} /> : <SaveAsIcon className={iconSize} />}
|
|
|
|
</NavButton>
|
|
|
|
)}
|
|
|
|
{control >= controlLevels.views.export && (
|
|
|
|
<NavButton
|
|
|
|
onClick={() => setView('export')}
|
|
|
|
label={t('workbench:exportPattern')}
|
|
|
|
active={view === 'export'}
|
|
|
|
>
|
|
|
|
<ExportIcon className={iconSize} />
|
|
|
|
</NavButton>
|
|
|
|
)}
|
|
|
|
{control >= controlLevels.views.edit && (
|
|
|
|
<NavButton
|
|
|
|
onClick={() => setView('edit')}
|
2023-11-03 19:41:21 +01:00
|
|
|
label={t('workbench:editSettingsByHand')}
|
2023-10-04 20:31:40 +02:00
|
|
|
active={view === 'edit'}
|
|
|
|
>
|
|
|
|
<EditIcon className={iconSize} />
|
|
|
|
</NavButton>
|
|
|
|
)}{' '}
|
|
|
|
{control >= controlLevels.views.logs && (
|
|
|
|
<NavButton
|
|
|
|
onClick={() => setView('logs')}
|
|
|
|
label={t('workbench:patternLogs')}
|
|
|
|
active={view === 'logs'}
|
|
|
|
>
|
|
|
|
<CodeIcon className={iconSize} />
|
|
|
|
</NavButton>
|
|
|
|
)}
|
|
|
|
{control >= controlLevels.views.inspect && (
|
|
|
|
<NavButton
|
|
|
|
onClick={() => setView('inspect')}
|
|
|
|
label={t('workbench:patternInspector')}
|
|
|
|
active={view === 'inspect'}
|
|
|
|
>
|
|
|
|
<XrayIcon className={iconSize} />
|
|
|
|
</NavButton>
|
|
|
|
)}
|
|
|
|
{control >= controlLevels.views.docs && (
|
|
|
|
<NavButton
|
|
|
|
onClick={() => setView('docs')}
|
|
|
|
label={t('workbench:docs')}
|
|
|
|
active={view === 'docs'}
|
|
|
|
>
|
|
|
|
<DocsIcon className={iconSize} />
|
|
|
|
</NavButton>
|
|
|
|
)}
|
2023-05-08 19:28:03 +02:00
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2023-10-04 20:31:40 +02:00
|
|
|
export const WorkbenchHeader = ({ view, setView, saveAs = false, control = 4 }) => {
|
2023-06-12 19:38:20 +02:00
|
|
|
const [dense, setDense] = useState(true)
|
2023-05-08 19:28:03 +02:00
|
|
|
return (
|
2023-06-24 16:49:28 -05:00
|
|
|
<MenuWrapper
|
2023-06-24 17:26:09 -05:00
|
|
|
Icon={icons[view]}
|
2023-06-26 12:23:21 -05:00
|
|
|
wrapperClass={`w-64 min-h-screen pt-4
|
2023-06-24 16:49:28 -05:00
|
|
|
bg-neutral
|
2023-06-26 12:23:21 -05:00
|
|
|
shrink-0 grow-0 self-stretch
|
2023-06-24 16:49:28 -05:00
|
|
|
transition-all
|
|
|
|
drop-shadow-xl
|
|
|
|
${dense ? '-ml-52' : 'ml-0'}`}
|
2023-06-24 17:26:09 -05:00
|
|
|
buttonClass={`order-last bottom-16`}
|
|
|
|
keepOpenOnClick={false}
|
2023-06-29 14:35:46 +00:00
|
|
|
order={0}
|
|
|
|
type="nav"
|
2023-05-08 19:28:03 +02:00
|
|
|
>
|
2023-06-24 16:49:28 -05:00
|
|
|
<header
|
2023-06-20 16:52:00 -05:00
|
|
|
className={`
|
2023-06-24 16:49:28 -05:00
|
|
|
sticky top-4 lg:top-28
|
|
|
|
group
|
|
|
|
`}
|
2023-06-20 16:52:00 -05:00
|
|
|
>
|
2023-06-24 16:49:28 -05:00
|
|
|
<div
|
|
|
|
className={`
|
|
|
|
flex flex-col
|
|
|
|
items-center w-full `}
|
|
|
|
>
|
2023-10-04 20:31:40 +02:00
|
|
|
<NavIcons {...{ setView, setDense, dense, view, saveAs, control }} />
|
2023-06-24 16:49:28 -05:00
|
|
|
</div>
|
|
|
|
</header>
|
|
|
|
</MenuWrapper>
|
2023-05-08 19:28:03 +02:00
|
|
|
)
|
|
|
|
}
|