diff --git a/src/components/AppBar/AppBar.css b/src/components/AppBar/AppBar.css deleted file mode 100644 index f2be905..0000000 --- a/src/components/AppBar/AppBar.css +++ /dev/null @@ -1,32 +0,0 @@ -.appBar { - height: 40px; - justify-content: space-between; - border-bottom: 1px solid var(--codex-border-color); - view-transition-name: main-header; - display: flex; - padding: 0.75rem 1.5rem; -} - -.appBar-burger { - cursor: pointer; - color: var(--codex-color); - display: flex; -} - -.appBar, -.appBar-left, -.appBar-right { - display: flex; - align-items: center; -} - -.appBar-left, -.appBar-right { - gap: 0.75rem; -} - -@media (min-width: 1000px) { - .appBar-burger { - display: none; - } -} diff --git a/src/components/AppBar/AppBar.tsx b/src/components/AppBar/AppBar.tsx deleted file mode 100644 index 9c2ff63..0000000 --- a/src/components/AppBar/AppBar.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import { Menu } from "lucide-react"; -import { NetworkIndicator } from "../NetworkIndicator/NetworkIndicator"; -import { NodeIndicator } from "../NodeIndicator/NodeIndicator"; -import "./AppBar.css"; -import { ICON_SIZE } from "../../utils/constants"; - -type Props = { - onExpand: () => void; -}; - -export function AppBar({ onExpand }: Props) { - return ( -
-
- - - - Home -
-
- - -
-
- ); -} diff --git a/src/components/HttpNetworkIndicator/HttpNetworkIndicator.tsx b/src/components/HttpNetworkIndicator/HttpNetworkIndicator.tsx new file mode 100644 index 0000000..78e0883 --- /dev/null +++ b/src/components/HttpNetworkIndicator/HttpNetworkIndicator.tsx @@ -0,0 +1,10 @@ +import { NetworkIndicator } from "@codex/marketplace-ui-components"; +import { useNetwork } from "../../network/useNetwork"; + +export function HttpNetworkIndicator() { + const online = useNetwork(); + + const text = online ? "Online" : "Offline"; + + return ; +} diff --git a/src/components/Menu/Menu.css b/src/components/Menu/Menu.css deleted file mode 100644 index 3853ef0..0000000 --- a/src/components/Menu/Menu.css +++ /dev/null @@ -1,64 +0,0 @@ -.menu { - display: flex; - flex-direction: column; - background-color: var(--codex-background-secondary); - border-radius: var(--codex-border-radius); - transform: translatex(-224px); - transition: transform 0.25s; - position: fixed; - min-width: 200px; - z-index: 1; - view-transition-name: main-menu; - height: 100%; -} - -.menu-container { - padding: 0.75rem; -} - -.menu-backdrop { - display: none; -} - -.menu[aria-expanded] { - transform: translatex(0); - min-width: 200px; -} - -.menu-header { - margin-bottom: 0.75rem; -} - -.menu-item, -.menu-header { - display: flex; - align-items: center; - gap: 0.75rem; -} - -.menu-item { - padding: 0.75rem; - color: var(--codex-color); - margin-bottom: 0.75rem; -} - -.menu-item:hover, -.menu-item.active { - background-color: var(--codex-background-light); -} - -.menu-title { - text-transform: uppercase; - padding-top: 0.75rem; - padding-bottom: 0.75rem; - padding-left: 0.75rem; - display: inline-block; - font-weight: 500; -} - -@media (min-width: 1000px) { - .menu { - transform: translatex(0px); - position: inherit; - } -} diff --git a/src/components/Menu/Menu.tsx b/src/components/Menu/Menu.tsx deleted file mode 100644 index 8feb899..0000000 --- a/src/components/Menu/Menu.tsx +++ /dev/null @@ -1,83 +0,0 @@ -import { - Home, - Star, - Server, - Settings, - HelpCircle, - ShoppingBag, -} from "lucide-react"; -import { attributes } from "../../utils/attributes"; -import { Link } from "@tanstack/react-router"; -import "./Menu.css"; -import logo from "../../assets/logo-inverse.svg"; -import { ICON_SIZE } from "../../utils/constants"; - -type Props = { - expanded: boolean; - onClose: () => void; -}; - -export function Menu({ expanded, onClose }: Props) { - const attr = attributes({ "aria-expanded": expanded }); - - return ( - <> -
- - - - ); -} diff --git a/src/components/NetworkIndicator/NetworkIndicator.tsx b/src/components/NetworkIndicator/NetworkIndicator.tsx deleted file mode 100644 index c1b01d2..0000000 --- a/src/components/NetworkIndicator/NetworkIndicator.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { useNetwork } from "../../network/useNetwork"; - -export function NetworkIndicator() { - const online = useNetwork(); - - if (online) { - return ( -
-
- Online -
- ); - } - - return ( -
-
- Offline -
- ); -} diff --git a/src/components/NodeIndicator/NodeIndicator.tsx b/src/components/NodeIndicator/NodeIndicator.tsx index 757139a..88ef5fc 100644 --- a/src/components/NodeIndicator/NodeIndicator.tsx +++ b/src/components/NodeIndicator/NodeIndicator.tsx @@ -2,6 +2,7 @@ import { useQuery, useQueryClient } from "@tanstack/react-query"; import { useEffect } from "react"; import { CodexSdk } from "../../sdk/codex"; import { Promises } from "../../utils/promises"; +import { NetworkIndicator } from "@codex/marketplace-ui-components"; function useNodeNetwork() { const { data, isError } = useQuery({ @@ -14,6 +15,8 @@ function useNodeNetwork() { refetchInterval: 5000, }); + // TODO handle error + return !isError && !!data; } @@ -28,19 +31,5 @@ export function NodeIndicator() { }); }, [queryClient, isCodexOnline]); - if (!isCodexOnline) { - return ( -
-
- Codex node -
- ); - } - - return ( -
-
- Codex node -
- ); + return ; } diff --git a/src/routes/dashboard.tsx b/src/routes/dashboard.tsx index 9598326..d48767d 100644 --- a/src/routes/dashboard.tsx +++ b/src/routes/dashboard.tsx @@ -1,26 +1,105 @@ -import { createFileRoute, Outlet } from "@tanstack/react-router"; -import { useState } from "react"; +import { createFileRoute, Link, Outlet } from "@tanstack/react-router"; import "./dashboard.css"; -import { Menu } from "../components/Menu/Menu"; -import { AppBar } from "../components/AppBar/AppBar"; +import { + MenuItem, + MenuItemComponentProps, + NetworkIndicator, + Page, +} from "@codex/marketplace-ui-components"; +import { + Home, + Star, + ShoppingBag, + Server, + Settings, + HelpCircle, +} from "lucide-react"; +import { ICON_SIZE } from "../utils/constants"; +import { NodeIndicator } from "../components/NodeIndicator/NodeIndicator"; +import { HttpNetworkIndicator } from "../components/HttpNetworkIndicator/HttpNetworkIndicator"; const Layout = () => { - const [expanded, setExpanded] = useState(false); - - const onExpand = () => setExpanded(true); - - const onClose = () => setExpanded(false); - - return ( + const Right = ( <> - - -
- - -
+ + ); + + const items = [ + { + type: "menu-item", + Component: (p: MenuItemComponentProps) => ( + + + Dashboard + + ), + }, + { + type: "menu-item", + Component: (p: MenuItemComponentProps) => ( + + + Favorites + + ), + }, + { + type: "separator", + }, + { + type: "menu-title", + title: "rent", + }, + { + type: "menu-item", + Component: (p: MenuItemComponentProps) => ( + + + Purchases + + ), + }, + { + type: "separator", + }, + { + type: "menu-title", + title: "host", + }, + { + type: "menu-item", + Component: (p: MenuItemComponentProps) => ( + + + Availabilities + + ), + }, + { + type: "menu-item", + Component: (p: MenuItemComponentProps) => ( + + + Settings + + ), + }, + { + type: "separator", + }, + { + type: "menu-item", + Component: (p: MenuItemComponentProps) => ( + + Help + + ), + }, + ] satisfies MenuItem[]; + + return } items={items} Right={Right} />; }; export const Route = createFileRoute("/dashboard")({