Skip to content

Commit

Permalink
Adds TrailingToolbar component
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbs committed Oct 25, 2023
1 parent 911afe1 commit 7dd89d7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/features/projects/view/client/ProjectsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function ProjectsPage({
onSelectProject={handleProjectSelected}
/>
}
toolbarTrailing={
trailingToolbar={
<ProjectsPageTrailingToolbarItem
stateContainer={stateContainer}
onSelectVersion={(versionId: string) => {
Expand Down
29 changes: 10 additions & 19 deletions src/features/sidebar/view/client/SidebarContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,38 @@

import dynamic from "next/dynamic"
import { ReactNode } from "react"
import { Box } from "@mui/material"
import { useTheme } from "@mui/material/styles"
import { useSessionStorage } from "usehooks-ts"
import ResponsiveSidebarContainer from "../base/responsive/SidebarContainer"
import Sidebar from "../Sidebar"
import SidebarHeader from "../SidebarHeader"
import TrailingToolbar from "./TrailingToolbar"

const SidebarContainer = ({
sidebar,
children,
toolbarTrailing
trailingToolbar
}: {
sidebar?: ReactNode
children?: ReactNode
toolbarTrailing?: ReactNode
trailingToolbar?: ReactNode
}) => {
const [open, setOpen] = useSessionStorage("isDrawerOpen", true)
const theme = useTheme()
return (
<ResponsiveSidebarContainer
isDrawerOpen={open}
onToggleDrawerOpen={setOpen}
primaryHeader={<SidebarHeader/>}
primaryHeader={
<SidebarHeader/>
}
primary={
<Sidebar>
{sidebar}
</Sidebar>
}
secondaryHeader={
<>
{toolbarTrailing != undefined &&
<Box sx={{
display: "flex",
width: "100%",
justifyContent: "right",
color: theme.palette.text.primary
}}>
{toolbarTrailing}
</Box>
}
</>
secondaryHeader={trailingToolbar &&
<TrailingToolbar>
{trailingToolbar}
</TrailingToolbar>
}
secondary={children}
/>
Expand Down
23 changes: 23 additions & 0 deletions src/features/sidebar/view/client/TrailingToolbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use client"

import { ReactNode } from "react"
import { Box } from "@mui/material"
import { useTheme } from "@mui/material/styles"

export default function TrailingToolbar({
children
}: {
children?: ReactNode
}) {
const theme = useTheme()
return (
<Box sx={{
display: "flex",
width: "100%",
justifyContent: "right",
color: theme.palette.text.primary
}}>
{children}
</Box>
)
}

0 comments on commit 7dd89d7

Please sign in to comment.