Skip to content

Commit

Permalink
Add back button to DocumentHeader
Browse files Browse the repository at this point in the history
  • Loading branch information
devleejb committed Jan 24, 2024
1 parent 4399da0 commit 0856e70
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions frontend/src/components/headers/DocumentHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
AppBar,
Avatar,
AvatarGroup,
IconButton,
Paper,
Stack,
ToggleButton,
Expand All @@ -20,9 +21,12 @@ import { useEffect } from "react";
import { useList } from "react-use";
import { ActorID } from "yorkie-js-sdk";
import { YorkieCodeMirrorPresenceType } from "../../utils/yorkie/yorkieSync";
import ArrowBackIosNewIcon from "@mui/icons-material/ArrowBackIosNew";
import { useNavigate } from "react-router-dom";

function DocumentHeader() {
const dispatch = useDispatch();
const navigate = useNavigate();
const editorState = useSelector(selectEditor);
const [
presenceList,
Expand Down Expand Up @@ -76,11 +80,20 @@ function DocumentHeader() {
dispatch(setMode(newMode));
};

const handleToPrevious = () => {
navigate(-1);
};

return (
<AppBar position="static" sx={{ zIndex: 100 }}>
<Toolbar>
<Stack width="100%" direction="row" justifyContent="space-between">
<Stack direction="row" spacing={1} alignItems="center">
<Tooltip title="Back to Previous Page">
<IconButton color="inherit" onClick={handleToPrevious}>
<ArrowBackIosNewIcon />
</IconButton>
</Tooltip>
<Paper>
{editorState.shareRole !== "READ" && (
<ToggleButtonGroup
Expand Down

0 comments on commit 0856e70

Please sign in to comment.