Skip to content

Commit

Permalink
UI improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
luloxi committed Oct 2, 2024
1 parent e7e9a3b commit c497707
Show file tree
Hide file tree
Showing 15 changed files with 543 additions and 29 deletions.
2 changes: 1 addition & 1 deletion packages/nextjs/app/create/_components/ImageUploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const ImageUploader: React.FC<ImageUploaderProps> = ({ image, setUploaded
return (
<div
className={`relative flex items-center justify-center w-60 h-60 rounded-lg shadow-lg ${
dragActive ? "bg-blue-400 border-2 border-blue-600" : ""
dragActive ? "bg-orange-400 border-2 border-orange-600" : ""
} ${previewImage ? "" : "bg-base-200"}`}
onDragOver={handleDragOver}
onDragLeave={handleDragLeave}
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/app/not-found/NotFound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { NextPage } from "next";

export const NotFound: NextPage = () => {
return (
<div className="flex flex-col bg-blue-800 justify-center items-center min-h-screen p-2">
<div className="flex flex-col bg-orange-800 justify-center items-center min-h-screen p-2">
{/* Not Found Section */}
<div className="relative text-red-500 flex flex-col justify-center items-center bg-base-100 p-6 rounded-lg shadow-md w-full">
<p className="font-bold text-2xl">Page under development</p>
Expand Down
7 changes: 6 additions & 1 deletion packages/nextjs/app/profile/[address]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,12 @@ const ProfilePage: NextPage = () => {

{bio && <p className="text-base-content">{bio}</p>}
{website && (
<a href={normalizeUrl(website)} target="_blank" rel="noopener noreferrer" className="text-blue-600">
<a
href={normalizeUrl(website)}
target="_blank"
rel="noopener noreferrer"
className="text-orange-600"
>
{website}
</a>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const ProfilePictureUpload: React.FC<ProfilePictureUploadProps> = ({
return (
<div
className={`relative flex items-center justify-center w-32 h-32 rounded-full shadow-lg ${
dragActive ? "bg-blue-500 border-2 border-blue-600" : "bg-base-200"
dragActive ? "bg-orange-500 border-2 border-orange-600" : "bg-base-200"
} ${previewImage ? "" : "bg-base-200"} `}
onDragOver={handleDragOver}
onDragLeave={handleDragLeave}
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/app/search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const Search = () => {
{error && <p className="text-red-500 mb-4">{error}</p>}
<button
onClick={handleSearch}
className="btn btn-primary w-full border-0 bg-blue-600 rounded-lg text-white py-2 px-4"
className="btn btn-primary w-full border-0 bg-orange-600 rounded-lg text-white py-2 px-4"
>
Go to profile
</button>
Expand Down
57 changes: 40 additions & 17 deletions packages/nextjs/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,30 @@ import Link from "next/link";
import { usePathname } from "next/navigation";
import Create from "../app/create/Create";
import Modal from "../app/create/Modal";
import { useAccount } from "wagmi";
import { HeartIcon } from "@heroicons/react/24/outline";
import { BellIcon, EnvelopeIcon, HomeIcon, MagnifyingGlassIcon, PlusIcon } from "@heroicons/react/24/solid";
import { useScaffoldReadContract } from "~~/hooks/scaffold-eth";

// Import Modal

/**
* Site footer
*/
export const Footer = () => {
const pathname = usePathname();
const [showPlusIcon, setShowPlusIcon] = useState(true);
const [isModalOpen, setIsModalOpen] = useState(false);
const [isAnimating, setIsAnimating] = useState(false);

const { address: connectedAddress } = useAccount();

const { data: profileInfo } = useScaffoldReadContract({
contractName: "ProfileInfo",
functionName: "profiles",
args: [connectedAddress],
watch: true,
});

const defaultProfilePicture = "/guest-profile.jpg";

const profilePicture = profileInfo && profileInfo[2] ? profileInfo[2] : defaultProfilePicture;

useEffect(() => {
let lastScrollY = window.scrollY;

Expand Down Expand Up @@ -53,7 +63,7 @@ export const Footer = () => {
<>
{pathname !== "/search" && (
<div
className={`fixed bottom-16 lg:bottom-8 right-8 p-3 bg-blue-600 cursor-pointer hover:bg-blue-800 text-white rounded-full shadow-lg ${
className={`fixed bottom-16 lg:bottom-8 right-8 p-3 bg-orange-600 cursor-pointer hover:bg-orange-800 text-white rounded-full shadow-lg ${
showPlusIcon ? "animate-show" : "animate-hide"
}`}
onClick={openModal}
Expand Down Expand Up @@ -95,29 +105,42 @@ export const Footer = () => {
</div>
</div>
<footer className="sticky lg:hidden bottom-0 w-full bg-base-100 px-4 py-2 flex justify-around items-center">
<Link href="/" passHref>
<HomeIcon className={`h-6 w-6 ${pathname === "/" ? "text-blue-600" : "hover:text-blue-600"}`} />
</Link>

<Link href="/search" passHref>
<MagnifyingGlassIcon
className={`h-6 w-6 ${pathname === "/search" ? "text-blue-600" : "hover:text-blue-600"}`}
<Link href="/not-found" passHref>
<EnvelopeIcon
className={`h-6 w-6 text-red-600 ${pathname === "/messages" ? "text-orange-600" : "hover:text-orange-600"}`}
/>
</Link>

<Link href="/not-found" passHref>
<BellIcon
className={`h-6 w-6 text-red-600 ${
pathname === "/notifications" ? "text-blue-600" : "hover:text-blue-600"
pathname === "/notifications" ? "text-orange-600" : "hover:text-orange-600"
}`}
/>
</Link>

<Link href="/not-found" passHref>
<EnvelopeIcon
className={`h-6 w-6 text-red-600 ${pathname === "/messages" ? "text-blue-600" : "hover:text-blue-600"}`}
<Link href="/" passHref>
<HomeIcon className={`h-6 w-6 ${pathname === "/" ? "text-orange-600" : "hover:text-orange-600"}`} />
</Link>

<Link href="/search" passHref>
<MagnifyingGlassIcon
className={`h-6 w-6 ${pathname === "/search" ? "text-orange-600" : "hover:text-orange-600"}`}
/>
</Link>

<div className="flex flex-row items-center justify-center gap-3">
<Link href={`/profile/${connectedAddress}`} passHref>
<div
className="w-8 h-8 rounded-full flex items-center justify-center cursor-pointer"
style={{
backgroundImage: `url(${profilePicture})`,
backgroundSize: "cover",
backgroundPosition: "center",
}}
></div>
</Link>
</div>
</footer>
</>
);
Expand Down
24 changes: 18 additions & 6 deletions packages/nextjs/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import React from "react";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { SwitchTheme } from "./SwitchTheme";
import { PunkBalance } from "./punk-society/PunkBalance";
import { PunkConnectButton } from "./punk-society/PunkConnectButton";
import { FaucetButton } from "./scaffold-eth";
import { useAccount } from "wagmi";
import { BellIcon, EnvelopeIcon, HomeIcon, MagnifyingGlassIcon } from "@heroicons/react/24/solid";
import { useScaffoldReadContract } from "~~/hooks/scaffold-eth";
Expand Down Expand Up @@ -37,7 +40,7 @@ export const Header = () => {
<Link href="/" passHref>
<button
className={`bg-transparent hover:bg-base-200 border-none hidden lg:flex flex-row items-center justify-center text-xl ${
pathname === "/" ? "text-blue-600" : ""
pathname === "/" ? "text-orange-600" : ""
}`}
>
<div className="flex flex-row items-center justify-center gap-2">
Expand All @@ -49,7 +52,7 @@ export const Header = () => {
<Link href="/search" passHref>
<button
className={`bg-transparent hover:bg-base-200 border-none hidden lg:flex flex-row items-center justify-center text-xl ${
pathname === "/search" ? "text-blue-600" : ""
pathname === "/search" ? "text-orange-600" : ""
}`}
>
<div className="flex flex-row items-center justify-center gap-2">
Expand All @@ -61,7 +64,7 @@ export const Header = () => {
<Link href="/not-found" passHref>
<button
className={`bg-transparent text-red-600 hover:bg-base-200 border-none hidden lg:flex flex-row items-center justify-center text-xl ${
pathname === "/notifications" ? "text-blue-600" : ""
pathname === "/notifications" ? "text-orange-600" : ""
}`}
>
<div className="flex flex-row items-center justify-center gap-2">
Expand All @@ -73,7 +76,7 @@ export const Header = () => {
<Link href="/not-found" passHref>
<button
className={`bg-transparent text-red-600 hover:bg-base-200 border-none hidden lg:flex flex-row items-center justify-center text-xl ${
pathname === "/messages" ? "text-blue-600" : ""
pathname === "/messages" ? "text-orange-600" : ""
}`}
>
<div className="flex flex-row items-center justify-center gap-2">
Expand All @@ -95,11 +98,20 @@ export const Header = () => {
</Link>
</div>

<div className="navbar-end mr-4 relative">
<div className="flex flex-row items-center justify-center gap-3">
<div className="navbar-end lg:mr-4 relative">
<div className="flex justify-center items-center gap-3 ">
<div className="hidden lg:flex">
<PunkBalance address={connectedAddress} usdMode />
</div>

<PunkConnectButton />
<FaucetButton />
</div>
<div className="hidden lg:flex flex-row items-center justify-center gap-3">
<div className="lg:mr-2">
<SwitchTheme />
</div>

<Link href={`/profile/${connectedAddress}`} passHref>
<div
className="w-8 h-8 rounded-full flex items-center justify-center cursor-pointer"
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/components/punk-society/LoadingBars.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
export const LoadingBars = () => {
return (
<div className="flex justify-center items-center mt-10">
<span className="loading text-blue-600 loading-bars loading-lg"></span>
<span className="loading text-orange-600 loading-bars loading-lg"></span>
{/* <div className="text-2xl text-primary-content ml-4"></div> */}
</div>
);
Expand Down
81 changes: 81 additions & 0 deletions packages/nextjs/components/punk-society/PunkBalance.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
"use client";

import { Address, formatEther } from "viem";
import { useNetworkColor } from "~~/hooks/scaffold-eth";
import { useDisplayUsdMode } from "~~/hooks/scaffold-eth/useDisplayUsdMode";
import { useTargetNetwork } from "~~/hooks/scaffold-eth/useTargetNetwork";
import { useWatchBalance } from "~~/hooks/scaffold-eth/useWatchBalance";
import { useGlobalState } from "~~/services/store/store";

type BalanceProps = {
address?: Address;
className?: string;
usdMode?: boolean;
};

/**
* Display (ETH & USD) balance of an ETH address.
*/
export const PunkBalance = ({ address, className = "", usdMode }: BalanceProps) => {
const { targetNetwork } = useTargetNetwork();
const networkColor = useNetworkColor();
const nativeCurrencyPrice = useGlobalState(state => state.nativeCurrency.price);
const isNativeCurrencyPriceFetching = useGlobalState(state => state.nativeCurrency.isFetching);

const {
data: balance,
isError,
isLoading,
} = useWatchBalance({
address,
});

const { displayUsdMode, toggleDisplayUsdMode } = useDisplayUsdMode({ defaultUsdMode: usdMode });

if (!address || isLoading || balance === null || (isNativeCurrencyPriceFetching && nativeCurrencyPrice === 0)) {
return (
<div className="animate-pulse flex space-x-4">
<div className="rounded-md bg-slate-300 h-6 w-6"></div>
<div className="flex items-center space-y-6">
<div className="h-2 w-28 bg-slate-300 rounded"></div>
</div>
</div>
);
}

if (isError) {
return (
<div className={`border-2 border-gray-400 rounded-md px-2 flex flex-col items-center max-w-fit cursor-pointer`}>
<div className="text-warning">Error</div>
</div>
);
}

const formattedBalance = balance ? Number(formatEther(balance.value)) : 0;

return (
<div className="flex flex-col items-center justify-center">
<button
className={`btn btn-sm btn-ghost flex flex-col font-normal items-center hover:bg-transparent ${className}`}
onClick={toggleDisplayUsdMode}
>
<div className="w-full flex items-center justify-center">
{displayUsdMode ? (
<>
<span className="text-[0.8em] font-bold mr-1">$</span>
<span>{(formattedBalance * nativeCurrencyPrice).toFixed(2)}</span>
</>
) : (
<>
<span>{formattedBalance.toFixed(4)}</span>
<span className="text-[0.8em] font-bold ml-1">{targetNetwork.nativeCurrency.symbol}</span>
</>
)}
</div>
</button>
<span className="text-xs" style={{ color: networkColor }}>
{targetNetwork.name}
</span>
</div>
);
};
Loading

0 comments on commit c497707

Please sign in to comment.