diff --git a/src/app/[netname]/bounty/[id]/page.tsx b/src/app/[netname]/bounty/[id]/page.tsx index 01f37cbb..9c063c3b 100644 --- a/src/app/[netname]/bounty/[id]/page.tsx +++ b/src/app/[netname]/bounty/[id]/page.tsx @@ -7,15 +7,23 @@ import 'react-toastify/dist/ReactToastify.css'; import BountyClaims from '@/components/bounty/BountyClaims'; import BountyInfo from '@/components/bounty/BountyInfo'; import CreateClaim from '@/components/ui/CreateClaim'; +import NavBarMobile from '@/components/global/NavBarMobile'; +import { useScreenSize } from '@/hooks/useScreenSize'; export default function Bounty({ params }: { params: { id: string } }) { + const isMobile = useScreenSize(); + return ( <>
- + {isMobile ? ( + + ) : ( + + )}
diff --git a/src/app/[netname]/page.tsx b/src/app/[netname]/page.tsx index f486c41c..acf62b64 100644 --- a/src/app/[netname]/page.tsx +++ b/src/app/[netname]/page.tsx @@ -6,13 +6,17 @@ import { ToastContainer } from 'react-toastify'; import 'react-toastify/dist/ReactToastify.css'; import ContentHome from '@/components/layout/ContentHome'; +import NavBarMobile from '@/components/global/NavBarMobile'; import CreateBounty from '@/components/ui/CreateBounty'; +import { useScreenSize } from '@/hooks/useScreenSize'; export default function Home() { + const isMobile = useScreenSize(); + return ( <> - + {isMobile ? : } ); diff --git a/src/components/global/GameButton.tsx b/src/components/global/GameButton.tsx index 968e0768..6c246dc9 100644 --- a/src/components/global/GameButton.tsx +++ b/src/components/global/GameButton.tsx @@ -1,10 +1,10 @@ export default function GameButton() { return ( - <> +
- +
); } diff --git a/src/components/global/NavBarMobile.tsx b/src/components/global/NavBarMobile.tsx new file mode 100644 index 00000000..030d56d1 --- /dev/null +++ b/src/components/global/NavBarMobile.tsx @@ -0,0 +1,62 @@ +import FormBounty from '@/components/global/FormBounty'; +import FormClaim from '@/components/global/FormClaim'; +import GameButton from '@/components/global/GameButton'; +import React, { useState } from 'react'; +import { toast } from 'react-toastify'; +import { useAccount } from 'wagmi'; + +export default function NavBarMobile({ + type, + bountyId, +}: { + type: 'claim' | 'bounty'; + bountyId?: string; +}) { + const [showForm, setShowForm] = useState(false); + const account = useAccount(); + return ( + <> + + + {type === 'bounty' ? ( + setShowForm(false)} /> + ) : ( + bountyId && ( + setShowForm(false)} + /> + ) + )} + + ); +} diff --git a/src/components/layout/Header.tsx b/src/components/layout/Header.tsx index 9d229f38..5815f5c4 100644 --- a/src/components/layout/Header.tsx +++ b/src/components/layout/Header.tsx @@ -40,7 +40,7 @@ const Header = () => { ]; return ( - <> +
setIsOpen(!cur)} @@ -102,7 +102,7 @@ const Header = () => {
- + ); }; diff --git a/src/components/ui/CreateBounty.tsx b/src/components/ui/CreateBounty.tsx index 33d5a7ea..65b95af7 100644 --- a/src/components/ui/CreateBounty.tsx +++ b/src/components/ui/CreateBounty.tsx @@ -13,7 +13,7 @@ export default function CreateBounty() {
{!showForm && (
{ if (account.isConnected) { setShowForm(true); diff --git a/src/components/ui/CreateClaim.tsx b/src/components/ui/CreateClaim.tsx index 6986f71b..5e9cda86 100644 --- a/src/components/ui/CreateClaim.tsx +++ b/src/components/ui/CreateClaim.tsx @@ -25,7 +25,7 @@ export default function CreateClaim({ bountyId }: { bountyId: string }) {
{!showForm && (
{ if (account.isConnected) { setShowForm(true); diff --git a/src/hooks/useScreenSize.ts b/src/hooks/useScreenSize.ts new file mode 100644 index 00000000..5dc76af4 --- /dev/null +++ b/src/hooks/useScreenSize.ts @@ -0,0 +1,18 @@ +import { useState, useEffect } from 'react'; + +export const useScreenSize = () => { + const [isMobile, setIsMobile] = useState(false); + + useEffect(() => { + const checkScreenSize = () => { + setIsMobile(window.innerWidth < 768); + }; + checkScreenSize(); + + window.addEventListener('resize', checkScreenSize); + + return () => window.removeEventListener('resize', checkScreenSize); + }, []); + + return isMobile; +};