Skip to content

Commit

Permalink
fix: adjust navigation alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
dominik-stumpf committed Nov 21, 2024
1 parent 8d5830f commit 9bed877
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 34 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"foxact": "^0.2.41",
"jotai": "^2.10.2",
"jotai": "^2.10.3",
"next": "15.0.3",
"next-themes": "^0.4.3",
"react": "19.0.0-rc-66855b96-20241106",
Expand Down
32 changes: 32 additions & 0 deletions src/app/explorer/_components/CreateGuildLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use client";

import { buttonVariants } from "@/components/ui/Button";
import { Plus } from "@phosphor-icons/react";
import { useAtomValue } from "jotai";
import Link from "next/link";
import { isNavStuckAtom } from "../atoms";

export const CreateGuildLink = () => {
const isNavStuck = useAtomValue(isNavStuckAtom);
return (
<Link
href="/create-guild"
aria-label="Create guild"
prefetch={false}
className={buttonVariants({
variant: "ghost",
size: "sm",
className: [
// Temporarily, until we don't migrate the scrollable Tabs component
"min-h-11 w-11 gap-1.5 px-0 sm:min-h-0 sm:w-auto sm:px-3",
{
"text-white": !isNavStuck,
},
],
})}
>
<Plus />
<span className="hidden sm:inline-block">Create guild</span>
</Link>
);
};
4 changes: 2 additions & 2 deletions src/app/explorer/_components/InfiniteScrollGuilds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useIntersection } from "foxact/use-intersection";
import { useAtomValue } from "jotai";
import { useCallback, useEffect } from "react";
import { searchAtom } from "../atoms";
import { ACTIVE_SECTION, PAGE_SIZE } from "../constants";
import { PAGE_SIZE } from "../constants";
import { getGuildSearch } from "../fetchers";

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

return (
<section className="grid gap-2" id={ACTIVE_SECTION.exploreGuilds}>
<section className="grid gap-2">
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
{isLoading
? Array.from({ length: PAGE_SIZE }, (_, i) => (
Expand Down
28 changes: 0 additions & 28 deletions src/app/explorer/_components/StickyBar.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
"use client";
import { buttonVariants } from "@/components/ui/Button";
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/ToggleGroup";
import useIsStuck from "@/hooks/useIsStuck";
import useScrollspy from "@/hooks/useScrollSpy";
import { cn } from "@/lib/cssUtils";
import { Plus } from "@phosphor-icons/react";
import { useAtom, useAtomValue, useSetAtom } from "jotai";
import Link from "next/link";
import { type PropsWithChildren, useEffect } from "react";
import { activeSectionAtom, isNavStuckAtom, isSearchStuckAtom } from "../atoms";
import { ACTIVE_SECTION } from "../constants";
Expand Down Expand Up @@ -70,31 +67,6 @@ const Nav = () => {
);
};

export const CreateGuildLink = () => {
const isNavStuck = useAtomValue(isNavStuckAtom);
return (
<Link
href="/create-guild"
aria-label="Create guild"
prefetch={false}
className={buttonVariants({
variant: "ghost",
size: "sm",
className: [
// Temporarily, until we don't migrate the scrollable Tabs component
"min-h-11 w-11 gap-1.5 px-0 sm:min-h-0 sm:w-auto sm:px-3",
{
"text-white": !isNavStuck,
},
],
})}
>
<Plus />
<span className="hidden sm:inline-block">Create guild</span>
</Link>
);
};

export const StickyBar = ({ children }: PropsWithChildren) => {
const setIsNavStuck = useSetAtom(isNavStuckAtom);
const isSearchStuck = useAtomValue(isSearchStuckAtom);
Expand Down
10 changes: 7 additions & 3 deletions src/app/explorer/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import {
dehydrate,
} from "@tanstack/react-query";
import { Suspense } from "react";
import { CreateGuildLink } from "./_components/CreateGuildLink";
import { HeaderBackground } from "./_components/HeaderBackground";
import { InfiniteScrollGuilds } from "./_components/InfiniteScrollGuilds";
import { StickySearch } from "./_components/Search";
import { CreateGuildLink, StickyBar } from "./_components/StickyBar";
import { StickyBar } from "./_components/StickyBar";
import { ACTIVE_SECTION } from "./constants";
import { getGuildSearch } from "./fetchers";

Expand All @@ -36,7 +37,7 @@ export default async function Explorer() {
return (
<>
<HeaderBackground />
<main className="container mx-auto grid max-w-screen-lg gap-8 px-4 py-8">
<main className="container mx-auto grid max-w-screen-lg gap-4 px-4 py-8">
<section className="pt-6 pb-8">
<h1
className="font-black font-display text-5xl tracking-tight"
Expand All @@ -53,7 +54,10 @@ export default async function Explorer() {
</StickyBar>
<YourGuildsSection />

<h2 className="mt-12 font-bold text-lg tracking-tight">
<h2
className="mt-12 font-bold text-lg tracking-tight"
id={ACTIVE_SECTION.exploreGuilds}
>
Explore verified guilds
</h2>
<StickySearch />
Expand Down

0 comments on commit 9bed877

Please sign in to comment.