Skip to content

Commit

Permalink
ui minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jog1t committed Sep 5, 2024
1 parent 748ce69 commit eb0af95
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 39 deletions.
1 change: 1 addition & 0 deletions apps/hub/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const router = createRouter({
},
// Since we're using React Query, we don't want loader calls to ever be stale
// This will ensure that the loader is always called when the route is preloaded or visited
defaultPreload: "intent",
defaultPreloadStaleTime: 0,
defaultOnCatch: (error) => {
Sentry.captureException(error);
Expand Down
2 changes: 1 addition & 1 deletion apps/hub/src/components/featured-modules-grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function FeaturesModulesGrid({ footer }: FeaturesModulesGridProps) {
<ModuleCard key={module.id} layoutAnimation={false} {...module} />
))}
</Grid>
{footer}
{footer ? <div className="text-right">{footer}</div> : null}
</motion.section>
);
}
Expand Down
29 changes: 21 additions & 8 deletions apps/hub/src/components/module-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ import {
library,
} from "@fortawesome/fontawesome-svg-core";
import { fab } from "@fortawesome/free-brands-svg-icons";
import { fas } from "@fortawesome/pro-solid-svg-icons";
import { faExternalLink, fas } from "@fortawesome/pro-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {
Card,
CardDescription,
CardHeader,
CardTitle,
Link,
Sheet,
SheetContent,
SheetDescription,
SheetHeader,
SheetTitle,
SheetTrigger,
Text,
} from "@rivet-gg/components";
import { motion } from "framer-motion";

Expand Down Expand Up @@ -82,13 +84,24 @@ export function ModuleCard({
</SheetTrigger>
<SheetContent className="sm:max-w-[500px]">
<SheetHeader>
<SheetTitle>{name} in OpenGB Docs</SheetTitle>
<SheetDescription className="-mx-6">
<iframe
className="w-full h-screen"
src={`https://opengb.dev/modules/${id}/overview`}
title={name}
/>
<SheetTitle>{name}</SheetTitle>
<Text className="text-xs">
<Link
href={`https://opengb.dev/modules/${id}/overview`}
target="_blank"
rel="noopener noreferrer"
>
Open in New Tab <FontAwesomeIcon icon={faExternalLink} />
</Link>
</Text>
<SheetDescription className="-mx-6" asChild>
<div>
<iframe
className="w-full h-screen border-t"
src={`https://opengb.dev/modules/${id}/overview`}
title={name}
/>
</div>
</SheetDescription>
</SheetHeader>
</SheetContent>
Expand Down
6 changes: 5 additions & 1 deletion apps/hub/src/domains/game/helpers/try-create-backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ export async function tryCreateBackend({
gameId,
environmentId,
queryClient,
}: { gameId: string; environmentId: string; queryClient: QueryClient }) {
}: {
gameId: string;
environmentId: string;
queryClient: QueryClient;
}) {
try {
await queryClient.fetchQuery(
gameBackendQueryOptions({ gameId, environmentId }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ function NamespaceIdRoute() {
}
const searchSchema = z.object({
modal: z.enum(["database", "create-server"]).or(z.string()).optional(),
search: z.string().optional(),
});
export const Route = createFileRoute(
"/_authenticated/_layout/games/$gameId/environments/$namespaceId",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
gameNamespaceQueryOptions,
gameVersionQueryOptions,
} from "@/domains/game/queries";
import { faArrowRight } from "@fortawesome/pro-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {
Button,
Grid,
Expand Down Expand Up @@ -41,7 +43,8 @@ function NamespaceIdRoute() {
to="/games/$gameId/environments/$namespaceId/modules"
params={params}
>
View all modules
View All Modules
<FontAwesomeIcon className="ml-2" icon={faArrowRight} />
</Link>
</RivetLink>
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { ModuleCard } from "@/components/module-card";
import { faBellConcierge, faUpload } from "@fortawesome/pro-solid-svg-icons";
import {
faBellConcierge,
faHammer,
faPlus,
} from "@fortawesome/pro-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {
Button,
Expand All @@ -18,20 +22,22 @@ import {
SidebarPage,
cn,
} from "@rivet-gg/components";
import { Link, createLazyFileRoute, useNavigate } from "@tanstack/react-router";
import { Link, createLazyFileRoute } from "@tanstack/react-router";
import { LayoutGroup, motion } from "framer-motion";
import { useState } from "react";
import OpenGBMeta from "../../../../../../../../vendor/opengb-modules-meta.json";

function GameIdModules() {
const navigate = useNavigate();
const search = Route.useSearch({ select: (s) => s.search || "" });
const [query, setQuery] = useState("");

const categories = OpenGBMeta.categories
.map((category) => {
const modules = category.modules.filter(
(module) =>
module.name.toLowerCase().includes(search.toLowerCase()) ||
module.description.toLowerCase().includes(search.toLowerCase()),
module.name.toLowerCase().includes((query || "").toLowerCase()) ||
module.description
.toLowerCase()
.includes((query || "").toLowerCase()),
);
return { ...category, modules };
})
Expand All @@ -40,9 +46,9 @@ function GameIdModules() {
return (
<>
<section className="flex flex-col gap-4 my-8">
<H1 className="text-center">Find a module</H1>
<H1 className="text-center">Backend Modules</H1>
<Lead className="text-center">
Add features to your game with modules.
Build your game&apos;s backend with open-source modules.
</Lead>

<Input asChild className="max-w-lg mx-auto">
Expand All @@ -52,19 +58,9 @@ function GameIdModules() {
className="text-muted-foreground mr-2"
/>
<input
value={search}
value={query}
onChange={(e) => {
if (e.target.value.length === 0) {
return navigate({ search: {} });
}
if (search.length === 0) {
navigate({ search: { search: e.target.value } });
} else {
navigate({
search: { search: e.target.value },
replace: true,
});
}
setQuery(e.target.value);
}}
placeholder="Search..."
className="bg-transparent border-transparent h-full w-full placeholder:text-muted-foreground focus-visible:outline-none"
Expand All @@ -89,13 +85,27 @@ function GameIdModules() {
{category.name}
</Link>
))}

<Button
variant="outline"
asChild
startIcon={<FontAwesomeIcon icon={faPlus} />}
>
<a
href="https://opengb.dev/docs/build/overview"
target="_blank"
rel="noopener noreferrer"
>
Build Your Own
</a>
</Button>
</SidebarNavigation>
}
>
<div>
<LayoutGroup>
{categories.length === 0 ? (
<Card className="w-1/2" asChild>
<Card className="w-full lg:w-1/2" asChild>
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
Expand All @@ -111,9 +121,8 @@ function GameIdModules() {
</CardTitle>
</CardHeader>
<CardContent>
Don't worry, OpenGB is created with extensibility in mind.
If you can't find a module that fits your needs, you can
request a new module or create your own.
If you can&apos;t find a module that fits your needs, you
can request a module to be created or build your own module.
</CardContent>
<CardFooter className="gap-2">
<Button
Expand All @@ -130,14 +139,14 @@ function GameIdModules() {
</Button>
<Button
asChild
startIcon={<FontAwesomeIcon icon={faUpload} />}
startIcon={<FontAwesomeIcon icon={faHammer} />}
>
<a
href="https://opengb.dev/docs/build/publish"
href="https://opengb.dev/docs/build/overview"
target="_blank"
rel="noopener noreferrer"
>
Publish Module
Build Your Own Module
</a>
</Button>
</CardFooter>
Expand Down

0 comments on commit eb0af95

Please sign in to comment.