Make left menu sidebar a Modal

GitOrigin-RevId: 63630c2a98c3abb5c5ebbde0afe25c0aa981282b
This commit is contained in:
Rebeka 2023-06-30 18:20:26 +02:00 committed by Copybot
parent a68518dd35
commit 7f5be3ed04
2 changed files with 55 additions and 12 deletions

View file

@ -2,26 +2,40 @@ import DownloadMenu from './download-menu'
import ActionsMenu from './actions-menu' import ActionsMenu from './actions-menu'
import HelpMenu from './help-menu' import HelpMenu from './help-menu'
import { useLayoutContext } from '../../../shared/context/layout-context' import { useLayoutContext } from '../../../shared/context/layout-context'
import classNames from 'classnames'
import SyncMenu from './sync-menu' import SyncMenu from './sync-menu'
import SettingsMenu from './settings-menu' import SettingsMenu from './settings-menu'
import LeftMenuMask from './left-menu-mask' import LeftMenuMask from './left-menu-mask'
import AccessibleModal from '../../../shared/components/accessible-modal'
import { Modal } from 'react-bootstrap'
import classNames from 'classnames'
export default function EditorLeftMenu() { export default function EditorLeftMenu() {
const { leftMenuShown } = useLayoutContext() const { leftMenuShown, setLeftMenuShown } = useLayoutContext()
const closeModal = () => {
setLeftMenuShown(false)
}
return ( return (
<> <>
<aside <AccessibleModal
id="left-menu" backdropClassName="left-menu-modal-backdrop"
className={classNames('full-size', { shown: leftMenuShown })} keyboard
onHide={closeModal}
id="left-menu-modal"
show={leftMenuShown}
> >
<DownloadMenu /> <Modal.Body
<ActionsMenu /> className={classNames('full-size', { shown: leftMenuShown })}
<SyncMenu /> id="left-menu"
<SettingsMenu /> >
<HelpMenu /> <DownloadMenu />
</aside> <ActionsMenu />
<SyncMenu />
<SettingsMenu />
<HelpMenu />
</Modal.Body>
</AccessibleModal>
{leftMenuShown && <LeftMenuMask />} {leftMenuShown && <LeftMenuMask />}
</> </>
) )

View file

@ -11,8 +11,8 @@
-webkit-transition: left ease-in-out @left-menu-animation-duration; -webkit-transition: left ease-in-out @left-menu-animation-duration;
transition: left ease-in-out @left-menu-animation-duration; transition: left ease-in-out @left-menu-animation-duration;
font-size: 14px; font-size: 14px;
left: -280px; left: -280px;
&.shown { &.shown {
left: 0; left: 0;
} }
@ -190,3 +190,32 @@
z-index: 99; z-index: 99;
transition: opacity 0.5s; transition: opacity 0.5s;
} }
// Make the Bootstrap Modal behavior as a left sidebar
#left-menu-modal {
opacity: 1;
.modal-dialog {
height: 100%;
margin: 0;
width: @left-menu-width;
}
.modal-content {
position: initial;
}
&.modal.fade .modal-dialog {
left: -280px;
transition: left ease-in-out @left-menu-animation-duration;
-webkit-transition: left ease-in-out @left-menu-animation-duration;
transform: translate(0, 0);
}
&.modal.in .modal-dialog {
left: 0;
transform: translate(0, 0);
}
}
// Don't disable backdrop that allows closing the Modal when clicking outside of it,
// But match its background color with the original mask background color.
.left-menu-modal-backdrop {
background-color: transparent;
}