1
0
Fork 0
freesewing/packages/freesewing.shared/components/workbench/menu/xray/index.js
2022-02-08 20:49:19 +01:00

52 lines
1.6 KiB
JavaScript

import XrayIcon from 'shared/components/icons/xray.js'
import { linkClasses, Chevron } from 'shared/components/navigation/primary.js'
import Reset from './reset.js'
import Disable from './disable.js'
import List from './list.js'
import { Ul, Details, TopSummary } from 'shared/components/workbench/menu'
import { useTranslation } from 'next-i18next'
const Xray = props => {
const { t } = useTranslation(['app', 'settings'])
return (
<Details open>
<TopSummary icon={<XrayIcon />}>
{props.gist?.xray?.enabled
? (
<>
<span className={`grow ${linkClasses} hover:cursor-resize font-bold uppercase`}>
{t('settings:xray.title')}
</span>
<Chevron />
</>
) : (
<>
<button
className={`grow ${linkClasses} hover:cursor-resize uppercase font-bold text-left`}
onClick={() => props.updateGist(['xray', 'enabled'], true)}
>
{t('settings:xray.title')}
</button>
<span className="text-normal text-secondary">
{t('cfp:thingIsDisabled', { thing: t('settings:xray.title') })}
</span>
</>
)
}
</TopSummary>
{props.gist?.xray?.enabled && (
<Ul>
<Disable {...props} />
<Reset {...props} />
{
props.gist?.xray?.parts &&
Object.keys(props.gist.xray.parts).map(partName => <List {...props} partName={partName} />)
}
</Ul>
)}
</Details>
)
}
export default Xray