-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to toggle Scroll Sync On/Off (#394)
* Add scroll sync enable options * Change `themeMode` comparison to strict equality
- Loading branch information
Showing
6 changed files
with
96 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { | ||
ListItemIcon, | ||
ListItemText, | ||
MenuItem, | ||
MenuList, | ||
Popover, | ||
PopoverProps, | ||
} from "@mui/material"; | ||
import { useDispatch, useSelector } from "react-redux"; | ||
import { selectConfig, setDisableScrollSync, setTheme, ThemeType } from "../../store/configSlice"; | ||
import { useCurrentTheme } from "../../hooks/useCurrentTheme"; | ||
import DarkModeIcon from "@mui/icons-material/DarkMode"; | ||
import LightModeIcon from "@mui/icons-material/LightMode"; | ||
import ToggleOnIcon from "@mui/icons-material/ToggleOn"; | ||
import ToggleOffIcon from "@mui/icons-material/ToggleOff"; | ||
|
||
function DocumentPopover(props: PopoverProps) { | ||
const dispatch = useDispatch(); | ||
const themeMode = useCurrentTheme(); | ||
const configStore = useSelector(selectConfig); | ||
|
||
const handleChangeTheme = () => { | ||
dispatch(setTheme(themeMode === ThemeType.LIGHT ? ThemeType.DARK : ThemeType.LIGHT)); | ||
}; | ||
|
||
const handleScrollSyncChange = () => { | ||
dispatch(setDisableScrollSync(!configStore.disableScrollSync)); | ||
}; | ||
|
||
return ( | ||
<Popover | ||
anchorOrigin={{ | ||
vertical: "bottom", | ||
horizontal: "right", | ||
}} | ||
transformOrigin={{ | ||
vertical: "top", | ||
horizontal: "right", | ||
}} | ||
{...props} | ||
> | ||
<MenuList> | ||
<MenuItem onClick={handleChangeTheme}> | ||
<ListItemIcon> | ||
{themeMode === "light" ? <LightModeIcon /> : <DarkModeIcon />} | ||
</ListItemIcon> | ||
<ListItemText>Appearance</ListItemText> | ||
</MenuItem> | ||
<MenuItem onClick={handleScrollSyncChange}> | ||
<ListItemIcon> | ||
{configStore.disableScrollSync ? ( | ||
<ToggleOffIcon /> | ||
) : ( | ||
<ToggleOnIcon color="primary" /> | ||
)} | ||
</ListItemIcon> | ||
<ListItemText>Panel Scroll Sync</ListItemText> | ||
</MenuItem> | ||
</MenuList> | ||
</Popover> | ||
); | ||
} | ||
|
||
export default DocumentPopover; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters