Expand header into multiple components (related #51)
This commit is contained in:
parent
ccf43f13b3
commit
bf60cde52c
|
@ -1,4 +1,4 @@
|
|||
import { Header } from "./Header";
|
||||
import { Header } from "./Header/Header";
|
||||
import { AppContext, useAppContext } from "../contexts/AppContext";
|
||||
import { CanvasWrapper } from "./CanvasWrapper";
|
||||
import { TemplateContext } from "../contexts/TemplateContext";
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
import { Button, Card, CardBody, Link } from "@nextui-org/react";
|
||||
import { useAppContext } from "../contexts/AppContext";
|
||||
import { User } from "./Header/User";
|
||||
import { Debug } from "@sc07-canvas/lib/src/debug";
|
||||
import React, { lazy } from "react";
|
||||
|
||||
const OpenChatButton = lazy(() => import("./Chat/OpenChatButton"));
|
||||
|
||||
const DynamicChat = () => {
|
||||
const { loadChat } = useAppContext();
|
||||
|
||||
return <React.Suspense>{loadChat && <OpenChatButton />}</React.Suspense>;
|
||||
};
|
||||
|
||||
export const Header = () => {
|
||||
const { setSettingsSidebar, connected, hasAdmin, setInfoSidebar } =
|
||||
useAppContext();
|
||||
|
||||
return (
|
||||
<header id="main-header">
|
||||
<div className="box">
|
||||
<Button onPress={() => setInfoSidebar(true)}>Info</Button>
|
||||
</div>
|
||||
<div className="spacer"></div>
|
||||
{!connected && (
|
||||
<div>
|
||||
<Card>
|
||||
<CardBody>Disconnected</CardBody>
|
||||
</Card>
|
||||
</div>
|
||||
)}
|
||||
<div className="spacer"></div>
|
||||
<div className="box">
|
||||
<User />
|
||||
<Button onClick={() => setSettingsSidebar(true)}>Settings</Button>
|
||||
<Button onClick={() => Debug.openDebugTools()}>debug</Button>
|
||||
{hasAdmin && (
|
||||
<Button href="/admin" target="_blank" as={Link}>
|
||||
Admin
|
||||
</Button>
|
||||
)}
|
||||
<DynamicChat />
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,61 @@
|
|||
import { Button, Card, CardBody, Link } from "@nextui-org/react";
|
||||
import { useAppContext } from "../../contexts/AppContext";
|
||||
import { User } from "./User";
|
||||
import { Debug } from "@sc07-canvas/lib/src/debug";
|
||||
import React, { lazy } from "react";
|
||||
|
||||
const OpenChatButton = lazy(() => import("../Chat/OpenChatButton"));
|
||||
|
||||
const DynamicChat = () => {
|
||||
const { loadChat } = useAppContext();
|
||||
|
||||
return <React.Suspense>{loadChat && <OpenChatButton />}</React.Suspense>;
|
||||
};
|
||||
|
||||
export const Header = () => {
|
||||
const { connected } = useAppContext();
|
||||
|
||||
return (
|
||||
<header id="main-header">
|
||||
<HeaderLeft />
|
||||
<div className="spacer"></div>
|
||||
{!connected && (
|
||||
<div>
|
||||
<Card>
|
||||
<CardBody>Disconnected</CardBody>
|
||||
</Card>
|
||||
</div>
|
||||
)}
|
||||
<div className="spacer"></div>
|
||||
<HeaderRight />
|
||||
</header>
|
||||
);
|
||||
};
|
||||
|
||||
const HeaderLeft = () => {
|
||||
const { setInfoSidebar } = useAppContext();
|
||||
|
||||
return (
|
||||
<div className="box">
|
||||
<Button onPress={() => setInfoSidebar(true)}>Info</Button>
|
||||
<Button onPress={() => Debug.openDebugTools()}>Debug Tools</Button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const HeaderRight = () => {
|
||||
const { setSettingsSidebar, hasAdmin } = useAppContext();
|
||||
|
||||
return (
|
||||
<div className="box">
|
||||
<User />
|
||||
<Button onClick={() => setSettingsSidebar(true)}>Settings</Button>
|
||||
{hasAdmin && (
|
||||
<Button href="/admin" target="_blank" as={Link}>
|
||||
Admin
|
||||
</Button>
|
||||
)}
|
||||
<DynamicChat />
|
||||
</div>
|
||||
);
|
||||
};
|
Loading…
Reference in New Issue