From c6d1bce7718391786ad21e8e6a8c8806d57e0847 Mon Sep 17 00:00:00 2001 From: Sean Date: Thu, 18 Dec 2025 21:06:08 -0500 Subject: [PATCH] setting up dark/white mode. fixed some other small things --- app/(builder)/builder/Untitled | 1 + app/(builder)/builder/build/page.tsx | 4 +- app/(builder)/builder/page.tsx | 50 +++++----- app/(builder)/layout.tsx | 11 +-- app/layout.tsx | 31 ++++-- components/BuilderNav.tsx | 128 ++++++++++++++++++++----- components/ThemeToggle.tsx | 49 ++++++++++ components/TopNav.tsx | 28 +++--- components/parts/PartsBrowseClient.tsx | 8 ++ components/parts/PartsGrid.tsx | 48 +++++----- tailwind.config.ts | 9 +- 11 files changed, 260 insertions(+), 107 deletions(-) create mode 100644 app/(builder)/builder/Untitled create mode 100644 components/ThemeToggle.tsx diff --git a/app/(builder)/builder/Untitled b/app/(builder)/builder/Untitled new file mode 100644 index 0000000..2dd6ac0 --- /dev/null +++ b/app/(builder)/builder/Untitled @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/app/(builder)/builder/build/page.tsx b/app/(builder)/builder/build/page.tsx index 2201882..0917fbc 100644 --- a/app/(builder)/builder/build/page.tsx +++ b/app/(builder)/builder/build/page.tsx @@ -319,8 +319,8 @@ export default function BuildSummaryPage() { ); return ( -
-
+
+
{/* Header */}
diff --git a/app/(builder)/builder/page.tsx b/app/(builder)/builder/page.tsx index e82d5ff..b8e7125 100644 --- a/app/(builder)/builder/page.tsx +++ b/app/(builder)/builder/page.tsx @@ -7,7 +7,7 @@ import { CATEGORIES } from "@/data/gunbuilderParts"; import { BUILDER_SLOTS, isSlotSatisfied } from "@/data/builderSlots"; import type { CategoryId, Part } from "@/types/gunbuilder"; import { PART_ROLE_TO_CATEGORY } from "@/lib/catalogMappings"; -import { Pencil, Link2, Square, CheckSquare } from "lucide-react"; +import { Pencil, X, Link2, Square, CheckSquare } from "lucide-react"; // ✅ Centralized overlap rules + helpers import OverlapChip from "@/components/builder/OverlapChip"; @@ -164,7 +164,9 @@ export default function GunbuilderPage() { const selectedParts: Part[] = useMemo(() => { const seen = new Set(); const resolved = Object.values(build) - .map((partId) => (partId ? parts.find((p) => p.id === partId) : undefined)) + .map((partId) => + partId ? parts.find((p) => p.id === partId) : undefined + ) .filter(Boolean) as Part[]; return resolved.filter((p) => { @@ -368,7 +370,7 @@ export default function GunbuilderPage() { brand: p.brand, price: p.price ?? 0, imageUrl: - ((p as any).imageUrl ?? (p as any).mainImageUrl) ?? undefined, + (p as any).imageUrl ?? (p as any).mainImageUrl ?? undefined, affiliateUrl: buyUrl, url: buyUrl, notes: undefined, @@ -508,7 +510,9 @@ export default function GunbuilderPage() { const payload = JSON.stringify(build); const encoded = window.btoa(payload); const origin = window.location?.origin ?? ""; - const url = `${origin}/builder/build?build=${encodeURIComponent(encoded)}`; + const url = `${origin}/builder/build?build=${encodeURIComponent( + encoded + )}`; setShareUrl(url); } catch { setShareUrl(""); @@ -606,7 +610,7 @@ export default function GunbuilderPage() { }; return ( -
+
{/* Header */}
@@ -807,9 +811,9 @@ export default function GunbuilderPage() { {/* Layout */}

- Work top-down through the major sections. Each row shows your current - pick for that part type, with price and a direct buy link—or a quick - way to choose a part if you haven't picked one yet. + Work top-down through the major sections. Each row shows your + current pick for that part type, with price and a direct buy link—or + a quick way to choose a part if you haven't picked one yet.

{loading && ( @@ -955,19 +959,21 @@ export default function GunbuilderPage() {
{selectedPart && selectedPart.url ? ( <> - { + setBuild((prev) => { + const next = { ...prev }; + delete next[category.id]; + return next; + }); }} - className="hidden md:inline-flex items-center justify-center rounded-md border border-zinc-700 bg-zinc-900/70 px-2 py-1 hover:bg-zinc-800 hover:border-zinc-600 transition-colors" - aria-label="Change part" - title="Change part" + className="inline-flex items-center justify-center rounded-md border border-zinc-700 bg-zinc-900/70 px-2 py-1 hover:bg-red-500/15 hover:border-red-400 transition-colors" + aria-label="Remove part" + title="Remove part" > - - + + @@ -1027,4 +1031,4 @@ export default function GunbuilderPage() {
); -} \ No newline at end of file +} diff --git a/app/(builder)/layout.tsx b/app/(builder)/layout.tsx index f0fd9f0..3c38821 100644 --- a/app/(builder)/layout.tsx +++ b/app/(builder)/layout.tsx @@ -1,18 +1,15 @@ // app/(builder)/layout.tsx import type { ReactNode } from "react"; -import { AuthProvider } from "@/context/AuthContext"; import { BuilderNav } from "@/components/BuilderNav"; import { TopNav } from "@/components/TopNav"; export default function BuilderLayout({ children }: { children: ReactNode }) { return ( -
- - - -
{children}
-
+
+ + +
{children}
); } \ No newline at end of file diff --git a/app/layout.tsx b/app/layout.tsx index b7992de..da5a9fd 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -2,7 +2,6 @@ import "./globals.css"; import type { ReactNode } from "react"; import { AuthProvider } from "@/context/AuthContext"; - import { Banner } from "@/components/Banner"; export const metadata = { @@ -13,17 +12,31 @@ export const metadata = { description: "Build rifles smarter, not harder.", }; +const themeScript = ` +(function () { + try { + const storedTheme = localStorage.getItem("theme"); + const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches; + const theme = storedTheme || (prefersDark ? "dark" : "light"); + document.documentElement.classList.toggle("dark", theme === "dark"); + } catch (_) {} +})(); +`; + export default function RootLayout({ children }: { children: ReactNode }) { return ( - - - - - - {children} - + + +