diff --git a/services/web/frontend/js/features/editor-left-menu/components/editor-left-menu.tsx b/services/web/frontend/js/features/editor-left-menu/components/editor-left-menu.tsx index 3e00fd058d..bd250f2f7c 100644 --- a/services/web/frontend/js/features/editor-left-menu/components/editor-left-menu.tsx +++ b/services/web/frontend/js/features/editor-left-menu/components/editor-left-menu.tsx @@ -5,9 +5,10 @@ import { useLayoutContext } from '../../../shared/context/layout-context' import classNames from 'classnames' import SyncMenu from './sync-menu' import SettingsMenu from './settings-menu' +import LeftMenuMask from './left-menu-mask' export default function EditorLeftMenu() { - const { leftMenuShown, setLeftMenuShown } = useLayoutContext() + const { leftMenuShown } = useLayoutContext() return ( <> @@ -21,10 +22,7 @@ export default function EditorLeftMenu() { - {leftMenuShown ? ( - // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions -
setLeftMenuShown(false)} /> - ) : null} + {leftMenuShown && } ) } diff --git a/services/web/frontend/js/features/editor-left-menu/components/left-menu-mask.tsx b/services/web/frontend/js/features/editor-left-menu/components/left-menu-mask.tsx new file mode 100644 index 0000000000..e606102967 --- /dev/null +++ b/services/web/frontend/js/features/editor-left-menu/components/left-menu-mask.tsx @@ -0,0 +1,31 @@ +import { memo, useEffect, useRef, useState } from 'react' +import { useLayoutContext } from '../../../shared/context/layout-context' +import useScopeValue from '../../../shared/hooks/use-scope-value' + +export default memo(function LeftMenuMask() { + const { setLeftMenuShown } = useLayoutContext() + const [editorTheme] = useScopeValue('settings.editorTheme') + const [overallTheme] = useScopeValue('settings.overallTheme') + const [original] = useState({ editorTheme, overallTheme }) + const maskRef = useRef(null) + + useEffect(() => { + if (maskRef.current) { + if ( + editorTheme !== original.editorTheme || + overallTheme !== original.overallTheme + ) { + maskRef.current.style.opacity = '0' + } + } + }, [editorTheme, overallTheme, original]) + + return ( + // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions +
setLeftMenuShown(false)} + /> + ) +}) diff --git a/services/web/frontend/stylesheets/app/editor/left-menu.less b/services/web/frontend/stylesheets/app/editor/left-menu.less index 5bae91a13a..010c3dec72 100644 --- a/services/web/frontend/stylesheets/app/editor/left-menu.less +++ b/services/web/frontend/stylesheets/app/editor/left-menu.less @@ -188,4 +188,5 @@ opacity: 0.4; background-color: #999; z-index: 99; + transition: opacity 0.5s; }