Skip to content

Commit

Permalink
chore: add header prereqs
Browse files Browse the repository at this point in the history
  • Loading branch information
dominik-stumpf committed Nov 21, 2024
1 parent 0d57765 commit d41eff8
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 22 deletions.
14 changes: 14 additions & 0 deletions public/images/robot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
23 changes: 23 additions & 0 deletions src/app/explorer/_components/HeaderBackground.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use client";

import { cn } from "@/lib/cssUtils";
import { useAtomValue } from "jotai";
import { isNavStuckAtom, isSearchStuckAtom } from "../atoms";

export const HeaderBackground = () => {
const isNavStuck = useAtomValue(isNavStuckAtom);
const isSearchStuck = useAtomValue(isSearchStuckAtom);

return (
<div
className={cn(
"fixed inset-x-0 top-0 z-10 h-0 bg-card shadow-md transition-all duration-200 dark:bg-background",
{
"h-16": isNavStuck,
"h-[calc(theme(space.36)+theme(space.2))] bg-gradient-to-b from-card to-background sm:h-[calc(theme(space.28)-theme(space.2))] dark:from-background dark:to-card-secondary/50":
isSearchStuck,
},
)}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useIntersection } from "foxact/use-intersection";
import { useAtomValue } from "jotai";
import { useCallback, useEffect } from "react";
import { searchAtom } from "../atoms";
import { PAGE_SIZE } from "../constants";
import { ACTIVE_SECTION, PAGE_SIZE } from "../constants";
import { getGuildSearch } from "../fetchers";

export const InfiniteScrollGuilds = () => {
Expand Down Expand Up @@ -45,7 +45,7 @@ export const InfiniteScrollGuilds = () => {
const guilds = data?.pages.flatMap((page) => page.items) || [];

return (
<section className="grid gap-2">
<section className="grid gap-2" id={ACTIVE_SECTION.exploreGuilds}>
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
{isLoading
? Array.from({ length: PAGE_SIZE }, (_, i) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const Search = () => {
window.history.replaceState(
null,
"",
`${pathname}?${newSearchParams.toString()}`,
[pathname, newSearchParams.toString()].filter(Boolean).join("?"),
);
}, [value, pathname]);

Expand Down
2 changes: 2 additions & 0 deletions src/app/explorer/atoms.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { atom } from "jotai";

export const searchAtom = atom<string | undefined>(undefined);
export const isNavStuckAtom = atom(false);
export const isSearchStuckAtom = atom(false);
4 changes: 4 additions & 0 deletions src/app/explorer/constants.ts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
export const PAGE_SIZE = 24;
export const ACTIVE_SECTION = {
yourGuilds: "your-guilds",
exploreGuilds: "explore-guilds",
};
48 changes: 29 additions & 19 deletions src/app/explorer/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import {
dehydrate,
} from "@tanstack/react-query";
import { Suspense } from "react";
import { InfiniteScrollGuilds } from "./components/InfiniteScrollGuilds";
import { Search } from "./components/Search";
import { HeaderBackground } from "./_components/HeaderBackground";
import { InfiniteScrollGuilds } from "./_components/InfiniteScrollGuilds";
import { Search } from "./_components/Search";
import { ACTIVE_SECTION } from "./constants";
import { getGuildSearch } from "./fetchers";

const getAssociatedGuilds = async () => {
Expand All @@ -32,21 +34,29 @@ export default async function Explorer() {
});

return (
<main className="container mx-auto grid max-w-screen-lg gap-8 px-4 py-8">
<section className="pt-6 pb-8">
<h1 className="font-black text-5xl">Guildhall</h1>
</section>

<YourGuildsSection />

<section>
<Search />
</section>

<HydrationBoundary state={dehydrate(queryClient)}>
<InfiniteScrollGuilds />
</HydrationBoundary>
</main>
<>
<HeaderBackground />
<main className="container mx-auto grid max-w-screen-lg gap-8 px-4 py-8">
<section className="pt-6 pb-8">
<h1
className="font-black font-display text-5xl tracking-tight"
id={ACTIVE_SECTION.yourGuilds}
>
Guildhall
</h1>
</section>

<YourGuildsSection />

<section>
<Search />
</section>

<HydrationBoundary state={dehydrate(queryClient)}>
<InfiniteScrollGuilds />
</HydrationBoundary>
</main>
</>
);
}

Expand All @@ -58,7 +68,7 @@ async function YourGuildsSection() {
<AuthBoundary
fallback={
<div className="flex items-center gap-4 rounded-2xl bg-card px-5 py-6">
<img src="/icons/robot.svg" alt="Guild Robot" className="size-8" />
<img src="/images/robot.svg" alt="Guild Robot" className="size-8" />

<p className="font-semibold">
Sign in to view your guilds or create new ones
Expand Down Expand Up @@ -93,7 +103,7 @@ async function YourGuilds() {
</div>
) : (
<div className="flex items-center gap-4 rounded-2xl bg-card px-5 py-6">
<img src="/icons/robot.svg" alt="Guild Robot" className="size-8" />
<img src="/images/robot.svg" alt="Guild Robot" className="size-8" />

<p className="font-semibold">
You&apos;re not a member of any guilds yet. Explore and join some below,
Expand Down

0 comments on commit d41eff8

Please sign in to comment.