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

55 lines
1.7 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'
2022-03-25 15:18:37 +01:00
import Log from './log.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 />}>
{props.gist?._state?.xray?.enabled
2022-01-29 14:51:13 +01:00
? (
<>
<span className={`grow ${linkClasses} hover:cursor-resize font-bold uppercase`}>
{t('settings:xray.t')}
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(['_state', 'xray', 'enabled'], true)}
2022-01-29 14:51:13 +01:00
>
{t('settings:xray.t')}
2022-01-29 14:51:13 +01:00
</button>
<span className="text-normal text-secondary">
{t('cfp:thingIsDisabled', { thing: t('settings:xray.t') })}
2022-01-29 14:51:13 +01:00
</span>
</>
)
}
2022-01-29 18:24:36 +01:00
</TopSummary>
{props.gist?._state?.xray?.enabled && (
2022-01-29 18:24:36 +01:00
<Ul>
2022-01-29 14:51:13 +01:00
<Disable {...props} />
2022-03-25 15:18:37 +01:00
<Log {...props} />
<Reset {...props} />
2022-01-29 14:51:13 +01:00
{
props.gist?._state?.xray?.parts &&
2022-03-13 08:48:21 +01:00
Object.keys(props.gist._state.xray.parts).map(partName => <List {...props} partName={partName} />)
2022-01-29 14:51:13 +01:00
}
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