mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-10 22:50:46 +02:00
b554b0cfcc
[web] Split editor theme into two when using system overall theme GitOrigin-RevId: 1efa5553fdff8a17de634017882feb2ede614cd6
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { memo, useEffect, useRef, useState } from 'react'
|
|
import { useLayoutContext } from '../../../shared/context/layout-context'
|
|
import { useUserSettingsContext } from '@/shared/context/user-settings-context'
|
|
|
|
export default memo(function LeftMenuMask() {
|
|
const { setLeftMenuShown } = useLayoutContext()
|
|
const { userSettings } = useUserSettingsContext()
|
|
const { editorTheme, editorLightTheme, editorDarkTheme, overallTheme } =
|
|
userSettings
|
|
const [original] = useState({
|
|
editorTheme,
|
|
overallTheme,
|
|
editorLightTheme,
|
|
editorDarkTheme,
|
|
})
|
|
const maskRef = useRef<HTMLDivElement | null>(null)
|
|
|
|
useEffect(() => {
|
|
if (maskRef.current) {
|
|
if (
|
|
editorTheme !== original.editorTheme ||
|
|
editorLightTheme !== original.editorLightTheme ||
|
|
editorDarkTheme !== original.editorDarkTheme ||
|
|
overallTheme !== original.overallTheme
|
|
) {
|
|
maskRef.current.style.opacity = '0'
|
|
}
|
|
}
|
|
}, [editorTheme, editorLightTheme, editorDarkTheme, 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)}
|
|
/>
|
|
)
|
|
})
|