-
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.
Update CodePair Workspace Page Layout with Recent Figma Design (#207)
* Remove login page * Change WorkspaceLayout * Remove unused import statement * Implement WorkspaceHeader * Implement WorkspaceDrawer * Implement Workspace Page * Implement member page * Change drawer option to permanent store * Fix typo * Add home button to `WorkspaceHeader` * Add theme change button in `ProfilePopover`
- Loading branch information
Showing
13 changed files
with
488 additions
and
302 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 was deleted.
Oops, something went wrong.
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,106 @@ | ||
import { MouseEventHandler, useState } from "react"; | ||
import { Avatar, IconButton, Stack, Toolbar, styled, useTheme } from "@mui/material"; | ||
import AppBar, { AppBarProps } from "@mui/material/AppBar"; | ||
import { DRAWER_WIDTH } from "../layouts/WorkspaceLayout"; | ||
import MenuIcon from "@mui/icons-material/Menu"; | ||
import { useSelector } from "react-redux"; | ||
import { selectUser } from "../../store/userSlice"; | ||
import ProfilePopover from "../popovers/ProfilePopover"; | ||
import KeyboardDoubleArrowLeftIcon from "@mui/icons-material/KeyboardDoubleArrowLeft"; | ||
import KeyboardDoubleArrowRightIcon from "@mui/icons-material/KeyboardDoubleArrowRight"; | ||
import CodePairIcon from "../icons/CodePairIcon"; | ||
import { useNavigate } from "react-router-dom"; | ||
import { selectWorkspace } from "../../store/workspaceSlice"; | ||
|
||
interface WorkspaceAppBarProps extends AppBarProps { | ||
open?: boolean; | ||
} | ||
|
||
const WorkspaceAppBar = styled(AppBar, { | ||
shouldForwardProp: (prop) => prop !== "open", | ||
})<WorkspaceAppBarProps>(({ theme, open }) => ({ | ||
transition: theme.transitions.create(["margin", "width"], { | ||
easing: theme.transitions.easing.sharp, | ||
duration: theme.transitions.duration.leavingScreen, | ||
}), | ||
...(open && { | ||
width: `calc(100% - ${DRAWER_WIDTH}px)`, | ||
marginLeft: `${DRAWER_WIDTH}px`, | ||
transition: theme.transitions.create(["margin", "width"], { | ||
easing: theme.transitions.easing.easeOut, | ||
duration: theme.transitions.duration.enteringScreen, | ||
}), | ||
}), | ||
})); | ||
|
||
interface WorkspaceHeaderProps { | ||
open: boolean; | ||
onDrawerOpen: () => void; | ||
} | ||
|
||
function WorkspaceHeader(props: WorkspaceHeaderProps) { | ||
const { open, onDrawerOpen } = props; | ||
const theme = useTheme(); | ||
const navigate = useNavigate(); | ||
const userStore = useSelector(selectUser); | ||
const workspaceStore = useSelector(selectWorkspace); | ||
const [profileAnchorEl, setProfileAnchorEl] = useState<(EventTarget & Element) | null>(null); | ||
|
||
const handleOpenProfilePopover: MouseEventHandler = (event) => { | ||
setProfileAnchorEl(event.currentTarget); | ||
}; | ||
|
||
const handleCloseProfilePopover = () => { | ||
setProfileAnchorEl(null); | ||
}; | ||
|
||
const handleToWorkspace = () => { | ||
navigate(`/${workspaceStore.data?.slug}`); | ||
}; | ||
|
||
return ( | ||
<WorkspaceAppBar position="fixed" open={open}> | ||
<Toolbar> | ||
<Stack | ||
width="100%" | ||
direction="row-reverse" | ||
justifyContent="space-between" | ||
alignItems="center" | ||
> | ||
<IconButton onClick={handleOpenProfilePopover}> | ||
<Avatar>{userStore.data?.nickname?.charAt(0)}</Avatar> | ||
</IconButton> | ||
<Stack direction="row"> | ||
<IconButton | ||
color="inherit" | ||
aria-label="open drawer" | ||
onClick={onDrawerOpen} | ||
edge="start" | ||
sx={{ mr: 2 }} | ||
> | ||
{open ? ( | ||
theme.direction === "ltr" ? ( | ||
<KeyboardDoubleArrowLeftIcon /> | ||
) : ( | ||
<KeyboardDoubleArrowRightIcon /> | ||
) | ||
) : ( | ||
<MenuIcon /> | ||
)} | ||
</IconButton> | ||
<IconButton onClick={handleToWorkspace}> | ||
<CodePairIcon /> | ||
</IconButton> | ||
</Stack> | ||
</Stack> | ||
</Toolbar> | ||
<ProfilePopover | ||
open={Boolean(profileAnchorEl)} | ||
anchorEl={profileAnchorEl} | ||
onClose={handleCloseProfilePopover} | ||
/> | ||
</WorkspaceAppBar> | ||
); | ||
} | ||
|
||
export default WorkspaceHeader; |
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
Oops, something went wrong.