-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement shadcn dark mode (#80)
* feat: implement shadcn dark mode * feat: implement shadcn dark mode and merge upstream changes
- Loading branch information
1 parent
92dcaf5
commit cd0d92c
Showing
18 changed files
with
1,172 additions
and
9,463 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,135 +1,96 @@ | ||
"use client"; | ||
|
||
import Link from "next/link"; | ||
import { useEffect, useState } from "react"; | ||
import { SafeSwapLogo } from "@/app/components/ui/SafeSwapLogo"; | ||
import { Button } from "@/app/components/ui/button"; | ||
import { Input } from "@/app/components/ui/input"; | ||
import DeliveryLocationButton from "@/app/components/ui/delivery-location-button"; | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuTrigger, | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuTrigger, | ||
} from "@/app/components/ui/dropdown-menu"; | ||
|
||
import DeliveryLocationButton from "@/app/components/ui/delivery-location-button"; | ||
import { MapPin } from 'lucide-react'; | ||
|
||
import { Input } from "@/app/components/ui/input"; | ||
import { ThemeToggle } from "@/app/components/ui/theme-toggle"; | ||
import { | ||
Search, | ||
ShoppingCart, | ||
Wallet, | ||
User, | ||
Settings, | ||
List, | ||
History, | ||
History, | ||
List, | ||
Search, | ||
Settings, | ||
ShoppingCart, | ||
User, | ||
Wallet, | ||
} from "lucide-react"; | ||
import { IoMoon, IoSunny } from "react-icons/io5"; | ||
import SubHeader from "./subheader/SubHeader"; | ||
|
||
import Link from "next/link"; | ||
import { useState } from "react"; | ||
|
||
export default function Header() { | ||
const [searchTerm, setSearchTerm] = useState<string>(""); | ||
const [dark, setDark] = useState(false); | ||
|
||
useEffect(() => { | ||
const darkMode = localStorage.getItem("darkMode"); | ||
if (darkMode) { | ||
setDark(JSON.parse(darkMode)); | ||
} | ||
}, []); | ||
|
||
useEffect(() => { | ||
if (typeof window !== "undefined") { | ||
document.documentElement.classList.toggle("dark", dark); | ||
localStorage.setItem("darkMode", JSON.stringify(dark)); | ||
} | ||
}, [dark]); | ||
|
||
const showSearchBar = searchTerm !== undefined && setSearchTerm !== undefined; | ||
const [searchTerm, setSearchTerm] = useState<string>(""); | ||
const showSearchBar = searchTerm !== undefined && setSearchTerm !== undefined; | ||
|
||
return ( | ||
<> | ||
<header className="flex items-center justify-between px-6 py-4 border-b"> | ||
<div className="flex items-center gap-4 min-w-max"> | ||
<Link href={"/"}> | ||
<SafeSwapLogo width={150} height={40} /> | ||
</Link> | ||
</div> | ||
<div className="flex items-center gap-4"> | ||
{showSearchBar ? ( | ||
<div className="relative w-full pl-2 max-w-[18.75rem] md:w-[18.75rem]"> | ||
<Input | ||
type="search" | ||
placeholder="Search products..." | ||
value={searchTerm} | ||
onChange={(e) => setSearchTerm(e.target.value)} | ||
className="w-full h-8 pr-10" | ||
/> | ||
<Button | ||
size="icon" | ||
variant="ghost" | ||
className="absolute right-0 top-0 h-full" | ||
> | ||
<Search className="h-5 w-5" /> | ||
<span className="sr-only">Search</span> | ||
</Button> | ||
</div> | ||
) : null} | ||
|
||
|
||
</div> | ||
<div className="flex gap-4"> | ||
<Button size="lg" className="group"> | ||
<DeliveryLocationButton /> | ||
<MapPin /> | ||
Country | ||
</Button> | ||
<Button size="lg" className="group"> | ||
<Wallet className="mr-2 h-4 w-4 transition-transform group-hover:scale-110" /> | ||
Connect Wallet | ||
</Button> | ||
<Button className="group h-auto"> | ||
<ShoppingCart className="h-5 w-5 transition-transform group-hover:scale-110" /> | ||
</Button> | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button className="group h-auto"> | ||
<User className="h-5 w-5 transition-transform group-hover:scale-110" /> | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent className="w-48"> | ||
<DropdownMenuItem> | ||
<User className="mr-2 h-4 w-4" /> | ||
Profile | ||
</DropdownMenuItem> | ||
<DropdownMenuItem> | ||
<List className="mr-2 h-4 w-4" /> | ||
My Listings | ||
</DropdownMenuItem> | ||
<DropdownMenuItem> | ||
<History className="mr-2 h-4 w-4" /> | ||
Transaction History | ||
</DropdownMenuItem> | ||
<DropdownMenuItem> | ||
<Settings className="mr-2 h-4 w-4" /> | ||
Settings | ||
</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
<button | ||
onClick={() => setDark(!dark)} | ||
className="p-2 rounded-full hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors" | ||
aria-label={dark ? "Switch to light mode" : "Switch to dark mode"} | ||
> | ||
{dark ? ( | ||
<IoSunny className="w-6 h-6" /> | ||
) : ( | ||
<IoMoon className="w-6 h-6" /> | ||
)} | ||
</button> | ||
</div> | ||
</header> | ||
</> | ||
); | ||
return ( | ||
<> | ||
<header className="flex items-center justify-between px-6 py-4 border-b"> | ||
<div className="flex items-center gap-4 min-w-max"> | ||
<Link href={"/"}> | ||
<SafeSwapLogo width={150} height={40} /> | ||
</Link> | ||
</div> | ||
{showSearchBar ? ( | ||
<div className="relative w-full pl-2 max-w-[18.75rem] md:w-[18.75rem]"> | ||
<Input | ||
type="search" | ||
placeholder="Search products..." | ||
value={searchTerm} | ||
onChange={(e) => setSearchTerm(e.target.value)} | ||
className="w-full h-8 pr-10" | ||
/> | ||
<Button | ||
size="icon" | ||
variant="ghost" | ||
className="absolute right-0 top-0 h-full" | ||
> | ||
<Search className="h-5 w-5" /> | ||
<span className="sr-only">Search</span> | ||
</Button> | ||
</div> | ||
) : null} | ||
<div className="flex gap-4"> | ||
<DeliveryLocationButton /> | ||
<Button size="lg" className="group"> | ||
<Wallet className="mr-2 h-4 w-4 transition-transform group-hover:scale-110" /> | ||
Connect Wallet | ||
</Button> | ||
<Button className="group h-auto"> | ||
<ShoppingCart className="h-5 w-5 transition-transform group-hover:scale-110" /> | ||
</Button> | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button className="group h-auto"> | ||
<User className="h-5 w-5 transition-transform group-hover:scale-110" /> | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent className="w-48"> | ||
<DropdownMenuItem> | ||
<User className="mr-2 h-4 w-4" /> | ||
Profile | ||
</DropdownMenuItem> | ||
<DropdownMenuItem> | ||
<List className="mr-2 h-4 w-4" /> | ||
My Listings | ||
</DropdownMenuItem> | ||
<DropdownMenuItem> | ||
<History className="mr-2 h-4 w-4" /> | ||
Transaction History | ||
</DropdownMenuItem> | ||
<DropdownMenuItem> | ||
<Settings className="mr-2 h-4 w-4" /> | ||
Settings | ||
</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
<ThemeToggle /> | ||
</div> | ||
</header> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,36 @@ | ||
"use client"; | ||
|
||
import { Button } from "@radix-ui/themes"; | ||
import BreadcrumbNavigation from "../../ui/breadcrumb-navigation"; | ||
import { CirclePlus } from "lucide-react"; | ||
import { useState } from "react"; | ||
import AddProductModal from "../../ui/add-product-modal"; | ||
import BreadcrumbNavigation from "../../ui/breadcrumb-navigation"; | ||
|
||
interface SubHeaderProps { | ||
name: string; | ||
name: string; | ||
} | ||
|
||
const SubHeader = ({ name }: SubHeaderProps) => { | ||
const [showModal, setShowModal] = useState(false); | ||
const [showModal, setShowModal] = useState(false); | ||
|
||
return ( | ||
<> | ||
<div className="flex justify-between items-center px-6 mt-4"> | ||
{/* Breadcrumb Navigation */} | ||
<BreadcrumbNavigation /> | ||
return ( | ||
<> | ||
<div className="flex justify-between items-center px-6 mt-4"> | ||
{/* Breadcrumb Navigation */} | ||
<BreadcrumbNavigation /> | ||
|
||
<Button | ||
className="flex items-center gap-2 bg-black cursor-pointer" | ||
onClick={() => setShowModal(true)} | ||
> | ||
<CirclePlus className="w-5 h-5" /> | ||
Add {name} | ||
</Button> | ||
</div> | ||
<Button | ||
className="flex items-center gap-2 bg-black cursor-pointer" | ||
onClick={() => setShowModal(true)} | ||
> | ||
<CirclePlus className="w-5 h-5" /> | ||
Add {name} | ||
</Button> | ||
</div> | ||
|
||
<AddProductModal | ||
isOpen={showModal} | ||
onClose={() => setShowModal(false)} | ||
/> | ||
</> | ||
); | ||
<AddProductModal isOpen={showModal} onClose={() => setShowModal(false)} /> | ||
</> | ||
); | ||
}; | ||
|
||
export default SubHeader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"use client"; | ||
|
||
import { ThemeProvider as NextThemesProvider } from "next-themes"; | ||
import { type ThemeProviderProps } from "next-themes"; | ||
import * as React from "react"; | ||
|
||
export function ThemeProvider({ children, ...props }: ThemeProviderProps) { | ||
return <NextThemesProvider {...props}>{children}</NextThemesProvider>; | ||
} |
Oops, something went wrong.