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,
|
|
|
|
BriefcaseIcon,
|
|
|
|
CodeIcon,
|
|
|
|
CutIcon,
|
2023-05-31 17:56:58 +02:00
|
|
|
HelpIcon,
|
2023-05-08 19:28:03 +02:00
|
|
|
OptionsIcon,
|
|
|
|
PrintIcon,
|
|
|
|
UploadIcon,
|
2023-06-12 19:38:20 +02:00
|
|
|
RightIcon,
|
|
|
|
LeftIcon,
|
|
|
|
DocsIcon,
|
|
|
|
SearchIcon,
|
2023-06-15 18:33:30 +02:00
|
|
|
MeasieIcon,
|
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-05-08 19:28:03 +02:00
|
|
|
|
|
|
|
export const ns = ['workbench', 'sections']
|
|
|
|
|
2023-06-12 19:38:20 +02:00
|
|
|
export const NavButton = ({
|
|
|
|
href,
|
|
|
|
label,
|
|
|
|
children,
|
|
|
|
onClick = false,
|
|
|
|
active = false,
|
|
|
|
extraClasses = 'bg-neutral text-neutral-content hover:bg-secondary hover:text-secondary-content',
|
|
|
|
}) => {
|
|
|
|
const className = `w-full flex flex-row items-center px-4 py-2 ${extraClasses} ${
|
|
|
|
active ? 'text-secondary' : ''
|
|
|
|
}`
|
|
|
|
const span = <span className="font-bold block grow text-left">{label}</span>
|
|
|
|
|
|
|
|
return onClick ? (
|
|
|
|
<button {...{ onClick, className }} title={label}>
|
|
|
|
{span}
|
|
|
|
{children}
|
|
|
|
</button>
|
|
|
|
) : (
|
|
|
|
<Link {...{ href, className }} title={label}>
|
|
|
|
{span}
|
|
|
|
{children}
|
|
|
|
</Link>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2023-06-15 18:53:45 +02:00
|
|
|
const NavIcons = ({ setView, setDense, dense, view }) => {
|
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-06-15 09:23:49 +02:00
|
|
|
label={t('workbench:viewMenu')}
|
2023-06-12 19:38:20 +02:00
|
|
|
extraClasses="text-success bg-neutral hover:bg-success hover:text-neutral"
|
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>
|
|
|
|
<NavButton
|
|
|
|
onClick={() => setView('draft')}
|
2023-06-15 18:33:30 +02:00
|
|
|
label={t('workbench:configurePattern')}
|
2023-05-08 19:28:03 +02:00
|
|
|
active={view === 'draft'}
|
|
|
|
>
|
|
|
|
<OptionsIcon className={iconSize} />
|
|
|
|
</NavButton>
|
2023-06-15 18:33:30 +02:00
|
|
|
<NavButton
|
|
|
|
onClick={() => setView('measies')}
|
|
|
|
label={t('workbench:measies')}
|
|
|
|
active={view === 'measies'}
|
|
|
|
>
|
|
|
|
<MeasieIcon className={iconSize} />
|
|
|
|
</NavButton>
|
2023-05-08 19:28:03 +02:00
|
|
|
<NavButton
|
|
|
|
onClick={() => setView('test')}
|
2023-06-15 09:23:49 +02:00
|
|
|
label={t('workbench:testPattern')}
|
2023-06-12 19:38:20 +02:00
|
|
|
active={view === 'test'}
|
2023-05-08 19:28:03 +02:00
|
|
|
>
|
|
|
|
<BeakerIcon className={iconSize} />
|
|
|
|
</NavButton>
|
|
|
|
<NavButton
|
|
|
|
onClick={() => setView('print')}
|
|
|
|
label={t('workbench:printLayout')}
|
2023-06-12 19:38:20 +02:00
|
|
|
active={view === 'print'}
|
2023-05-08 19:28:03 +02:00
|
|
|
>
|
|
|
|
<PrintIcon className={iconSize} />
|
|
|
|
</NavButton>
|
|
|
|
<NavButton
|
|
|
|
onClick={() => setView('cut')}
|
|
|
|
label={t('workbench:cutLayout')}
|
2023-06-12 19:38:20 +02:00
|
|
|
active={view === 'cut'}
|
2023-05-08 19:28:03 +02:00
|
|
|
>
|
|
|
|
<CutIcon className={iconSize} />
|
|
|
|
</NavButton>
|
|
|
|
<NavButton
|
|
|
|
onClick={() => setView('save')}
|
2023-06-15 09:23:49 +02:00
|
|
|
label={t('workbench:savePattern')}
|
2023-06-12 19:38:20 +02:00
|
|
|
active={view === 'save'}
|
2023-05-08 19:28:03 +02:00
|
|
|
>
|
|
|
|
<UploadIcon className={iconSize} />
|
|
|
|
</NavButton>
|
|
|
|
<NavButton
|
|
|
|
onClick={() => setView('export')}
|
2023-06-15 09:23:49 +02:00
|
|
|
label={t('workbench:exportPattern')}
|
2023-06-12 19:38:20 +02:00
|
|
|
active={view === 'export'}
|
2023-05-08 19:28:03 +02:00
|
|
|
>
|
|
|
|
<BriefcaseIcon className={iconSize} />
|
|
|
|
</NavButton>
|
|
|
|
<NavButton
|
|
|
|
onClick={() => setView('edit')}
|
2023-06-15 09:23:49 +02:00
|
|
|
label={t('workbench:editSettings')}
|
2023-06-12 19:38:20 +02:00
|
|
|
active={view === 'edit'}
|
2023-05-08 19:28:03 +02:00
|
|
|
>
|
|
|
|
<CodeIcon className={iconSize} />
|
|
|
|
</NavButton>
|
|
|
|
<NavButton
|
2023-06-12 19:38:20 +02:00
|
|
|
onClick={() => setView('logs')}
|
2023-06-15 09:23:49 +02:00
|
|
|
label={t('workbench:patternLogs')}
|
2023-06-12 19:38:20 +02:00
|
|
|
active={view === 'logs'}
|
2023-05-08 19:28:03 +02:00
|
|
|
>
|
2023-06-12 19:38:20 +02:00
|
|
|
<DocsIcon className={iconSize} />
|
2023-05-08 19:28:03 +02:00
|
|
|
</NavButton>
|
2023-06-12 19:38:20 +02:00
|
|
|
<NavButton
|
|
|
|
onClick={() => setView('inspect')}
|
2023-06-15 09:23:49 +02:00
|
|
|
label={t('workbench:patternInspector')}
|
2023-06-12 19:38:20 +02:00
|
|
|
active={view === 'inspect'}
|
|
|
|
>
|
|
|
|
<SearchIcon className={iconSize} />
|
|
|
|
</NavButton>
|
2023-06-15 09:23:49 +02:00
|
|
|
<NavButton label={t('workbench:docs')} href="/docs/site/draft">
|
2023-06-12 19:38:20 +02:00
|
|
|
<HelpIcon className={iconSize} />
|
2023-05-08 19:28:03 +02:00
|
|
|
</NavButton>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2023-06-15 19:03:19 +02:00
|
|
|
export const WorkbenchHeader = ({ view, setView }) => {
|
2023-06-12 19:38:20 +02:00
|
|
|
const [dense, setDense] = useState(true)
|
2023-05-08 19:28:03 +02:00
|
|
|
return (
|
|
|
|
<header
|
|
|
|
className={`
|
2023-06-20 16:52:00 -05:00
|
|
|
h-full w-64 min-h-screen pt-4
|
2023-05-08 19:28:03 +02:00
|
|
|
bg-neutral
|
2023-06-20 16:52:00 -05:00
|
|
|
|
2023-06-13 19:31:10 +02:00
|
|
|
transition-all
|
2023-05-08 19:28:03 +02:00
|
|
|
drop-shadow-xl
|
2023-06-13 19:31:10 +02:00
|
|
|
${dense ? '-ml-52' : 'ml-0'}
|
2023-06-20 16:52:00 -05:00
|
|
|
group
|
2023-05-08 19:28:03 +02:00
|
|
|
`}
|
|
|
|
>
|
2023-06-20 16:52:00 -05:00
|
|
|
<div
|
|
|
|
className={`
|
2023-06-21 23:11:14 -05:00
|
|
|
flex flex-col
|
|
|
|
items-center w-full sticky top-4 lg:top-28`}
|
2023-06-20 16:52:00 -05:00
|
|
|
>
|
2023-06-15 18:53:45 +02:00
|
|
|
<NavIcons {...{ setView, setDense, dense, view }} />
|
2023-05-08 19:28:03 +02:00
|
|
|
</div>
|
|
|
|
</header>
|
|
|
|
)
|
|
|
|
}
|