-
-
Notifications
You must be signed in to change notification settings - Fork 558
/
Copy pathtoolbar.tsx
67 lines (57 loc) · 1.58 KB
/
toolbar.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* SPDX-FileCopyrightText: 2014-present Kriasoft */
/* SPDX-License-Identifier: MIT */
import { ExpandMoreRounded, NotificationsRounded } from "@mui/icons-material";
import { Box, BoxProps, Button, IconButton } from "@mui/joy";
import { Fragment, Suspense } from "react";
import { Link } from "react-router-dom";
import { useCurrentUser } from "../core/auth";
import { ColorSchemeButton } from "./button-color-scheme";
import { UserAvatarButton } from "./button-user-avatar";
export function Toolbar(props: ToolbarProps): JSX.Element {
const { sx, ...other } = props;
return (
<Box
sx={{
alignItems: "center",
borderBottom: "1px solid",
borderColor: "divider",
display: "flex",
gap: 1,
px: 2,
...sx,
}}
component="header"
{...other}
>
<Button
color="neutral"
variant="plain"
endDecorator={<ExpandMoreRounded />}
children="Project Name"
/>
<Box sx={{ flexGrow: 1 }} component="span" />
<Suspense>
<ActionButtons />
</Suspense>
</Box>
);
}
function ActionButtons(): JSX.Element {
const user = useCurrentUser();
return (
<Fragment>
<ColorSchemeButton variant="soft" size="sm" />
<IconButton variant="soft" size="sm">
<NotificationsRounded />
</IconButton>
{user ? (
<UserAvatarButton variant="soft" />
) : (
<Button component={Link} size="sm" to="/login">
Sign In
</Button>
)}
</Fragment>
);
}
type ToolbarProps = Omit<BoxProps<"header">, "children">;