2023-05-24 06:03:58 -04:00
|
|
|
import { memo, useEffect, useRef, useState } from 'react'
|
|
|
|
import { useLayoutContext } from '../../../shared/context/layout-context'
|
2023-11-21 09:29:44 -05:00
|
|
|
import { useUserSettingsContext } from '@/shared/context/user-settings-context'
|
2023-05-24 06:03:58 -04:00
|
|
|
|
|
|
|
export default memo(function LeftMenuMask() {
|
|
|
|
const { setLeftMenuShown } = useLayoutContext()
|
2023-11-21 09:29:44 -05:00
|
|
|
const { userSettings } = useUserSettingsContext()
|
|
|
|
const { editorTheme, overallTheme } = userSettings
|
2023-05-24 06:03:58 -04:00
|
|
|
const [original] = useState({ editorTheme, overallTheme })
|
|
|
|
const maskRef = useRef<HTMLDivElement | null>(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
|
|
|
|
<div
|
|
|
|
id="left-menu-mask"
|
|
|
|
ref={maskRef}
|
|
|
|
onClick={() => setLeftMenuShown(false)}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
})
|