Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.

Commit 01b1e35

Browse files
committed
1 parent 3f872d0 commit 01b1e35

File tree

9 files changed

+59
-45
lines changed

9 files changed

+59
-45
lines changed

apps/hub/src/domains/project/components/servers/servers-list-panel.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ export function ServersListPanel({
6161
</Button>
6262
</div>
6363
) : (
64-
<SmallText className="text-muted-foreground text-center col-span-full">
64+
<SmallText className="text-muted-foreground text-center col-span-full my-4">
6565
{data.length === 0
66-
? "No servers found"
67-
: "No more servers to load"}
66+
? "No servers found."
67+
: "No more servers to load."}
6868
</SmallText>
6969
)}
7070
</>

apps/hub/src/domains/project/layouts/project-layout.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { computePageLayout } from "@/lib/compute-page-layout";
12
import { Page, Skeleton } from "@rivet-gg/components";
23
import { useMatches } from "@tanstack/react-router";
34
import type { PropsWithChildren, ReactNode } from "react";
@@ -8,11 +9,7 @@ interface ProjectPageProps {
89

910
function ProjectPage({ children }: ProjectPageProps) {
1011
const matches = useMatches();
11-
return (
12-
<Page layout={matches[matches.length - 1].staticData.layout}>
13-
{children}
14-
</Page>
15-
);
12+
return <Page layout={computePageLayout(matches)}>{children}</Page>;
1613
}
1714

1815
ProjectPage.Skeleton = Page.Skeleton;
@@ -37,11 +34,7 @@ Content.Skeleton = function ContentSkeleton() {
3734

3835
function EmptyProjectPage({ children }: PropsWithChildren) {
3936
const matches = useMatches();
40-
return (
41-
<Page layout={matches[matches.length - 1].staticData.layout}>
42-
{children}
43-
</Page>
44-
);
37+
return <Page layout={computePageLayout(matches)}>{children}</Page>;
4538
}
4639

4740
export { ProjectPage as Root, EmptyProjectPage as EmptyRoot, Content };

apps/hub/src/layouts/root.tsx

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,19 @@
11
import { CommandPanel } from "@/components/command-panel";
22
import { NavItem } from "@/components/header/nav-item";
3+
import { computePageLayout } from "@/lib/compute-page-layout";
34
import { publicUrl } from "@/lib/utils";
45
import { cn } from "@rivet-gg/components";
56
import { Icon, faDiscord, faGithub, faXTwitter } from "@rivet-gg/icons";
67
import { useMatches } from "@tanstack/react-router";
7-
import type { ReactNode } from "react";
8+
import type { PropsWithChildren, ReactNode } from "react";
89
import { Header as UiHeader } from "../components/header/header";
910

1011
interface RootProps {
1112
children: ReactNode;
1213
}
1314

1415
const Root = ({ children }: RootProps) => {
15-
const matches = useMatches();
16-
return (
17-
<div
18-
className={cn("flex min-h-screen flex-col", {
19-
"h-screen": matches[matches.length - 1].staticData.layout === "full",
20-
})}
21-
>
22-
{children}
23-
</div>
24-
);
16+
return <div className={cn("flex min-h-screen flex-col")}>{children}</div>;
2517
};
2618

2719
const Main = ({ children }: RootProps) => {
@@ -32,6 +24,21 @@ const Main = ({ children }: RootProps) => {
3224
);
3325
};
3426

27+
const VisibleInFull = ({ children }: PropsWithChildren) => {
28+
const matches = useMatches();
29+
const layout = computePageLayout(matches);
30+
return (
31+
<div
32+
className={cn({
33+
"min-h-screen grid grid-rows-[auto,1fr]": layout === "full",
34+
contents: layout !== "full",
35+
})}
36+
>
37+
{children}
38+
</div>
39+
);
40+
};
41+
3542
const Header = () => {
3643
return <UiHeader />;
3744
};
@@ -127,4 +134,4 @@ const Footer = () => {
127134
);
128135
};
129136

130-
export { Root, Main, Header, Footer };
137+
export { Root, Main, Header, Footer, VisibleInFull };
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type {
2+
MakeRouteMatchUnion,
3+
StaticDataRouteOption,
4+
} from "@tanstack/react-router";
5+
6+
export function computePageLayout(
7+
matches: MakeRouteMatchUnion[],
8+
): StaticDataRouteOption["layout"] {
9+
let layout: StaticDataRouteOption["layout"] = "compact";
10+
11+
for (const match of matches) {
12+
if (match.staticData.layout) {
13+
layout = match.staticData.layout;
14+
}
15+
}
16+
17+
return layout;
18+
}

apps/hub/src/routes/__root.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,13 @@ function RootErrorComponent(props: ErrorComponentProps) {
8585
function Root() {
8686
return (
8787
<Layout.Root>
88-
<Layout.Header />
89-
<Layout.Main>
90-
<Modals />
91-
<Outlet />
92-
</Layout.Main>
88+
<Layout.VisibleInFull>
89+
<Layout.Header />
90+
<Layout.Main>
91+
<Modals />
92+
<Outlet />
93+
</Layout.Main>
94+
</Layout.VisibleInFull>
9395
<Layout.Footer />
9496
</Layout.Root>
9597
);

apps/hub/src/routes/_authenticated/_layout.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import { computePageLayout } from "@/lib/compute-page-layout";
12
import { PageLayout } from "@rivet-gg/components/layout";
23
import { Outlet, createFileRoute, useMatches } from "@tanstack/react-router";
34

45
export const Route = createFileRoute("/_authenticated/_layout")({
56
component: () => {
67
const matches = useMatches();
78
return (
8-
<PageLayout.Root layout={matches[matches.length - 1].staticData.layout}>
9+
<PageLayout.Root layout={computePageLayout(matches)}>
910
<Outlet />
1011
</PageLayout.Root>
1112
);

apps/hub/src/routes/_authenticated/_layout/projects/$projectId/environments/$environmentId/servers.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
Button,
66
Card,
77
CardContent,
8-
CardDescription,
98
CardHeader,
109
CardTitle,
1110
Flex,
@@ -65,17 +64,14 @@ function ProjectServersRoute() {
6564
/>
6665
</Flex>
6766
</CardTitle>
68-
<CardDescription>
69-
Servers are created & destroyed automatically as players connect &
70-
disconnect.
71-
</CardDescription>
7267
</CardHeader>
7368
<CardContent className="flex-1 min-h-0 w-full p-0">
7469
{data.length === 0 ? (
7570
<div className="flex items-center mx-auto flex-col gap-2 my-10">
7671
<span>No servers created.</span>
7772
<span className="text-xs">
78-
Run your project client & connect to start a server.
73+
Servers are created & destroyed automatically as players connect &
74+
disconnect.
7975
</span>
8076
</div>
8177
) : (

packages/components/src/layout/page.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@ interface PageLayoutProps {
88

99
const PageLayout = ({ children, layout = "compact" }: PageLayoutProps) => (
1010
<div
11-
className={cn(
12-
{
13-
container: layout === "compact",
14-
"px-8 w-full flex-1 h-full flex min-h-0": layout === "full",
15-
},
16-
"pt-8",
17-
)}
11+
className={cn({
12+
"p-8 container": layout === "compact",
13+
"px-4 w-full h-full py-4": layout === "full",
14+
})}
1815
>
1916
{children}
2017
</div>

packages/components/src/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const Page = ({
2323
<Flex
2424
direction="col"
2525
gap="4"
26-
className={cn(className, layout === "full" && "flex-1 w-full")}
26+
className={cn(className, { "h-full": layout === "full" })}
2727
>
2828
{title ? <H1 className={cn(header ? "mt-8" : "my-8")}>{title}</H1> : null}
2929
{header}

0 commit comments

Comments
 (0)