1
0
Fork 0
freesewing/packages/freesewing.shared/components/workbench/menu/xray/index.js

53 lines
1.6 KiB
JavaScript
Raw Normal View History

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