Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fakepixels committed Oct 30, 2024
1 parent 863ecec commit 044a6f3
Show file tree
Hide file tree
Showing 16 changed files with 88 additions and 454 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:coverage": "vitest run --coverage"
},
"dependencies": {
"@coinbase/onchainkit": "^0.32.0",
"@coinbase/onchainkit": "^0.35.2",
"framer-motion": "^11.10.0",
"lucide": "^0.447.0",
"lucide-react": "^0.447.0",
Expand Down
1 change: 0 additions & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { NEXT_PUBLIC_URL } from '../config';

import './global.css';
import '@coinbase/onchainkit/styles.css';
import '@rainbow-me/rainbowkit/styles.css';
import dynamic from 'next/dynamic';

const OnchainProviders = dynamic(
Expand Down
20 changes: 11 additions & 9 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
'use client';
import { useAccount } from 'wagmi';
import Footer from 'src/components/Footer';
import IdentityWrapper from 'src/components/IdentityWrapper';
import { ONCHAINKIT_LINK } from 'src/links';
import OnchainkitSvg from 'src/svg/OnchainkitSvg';
import { useAccount } from 'wagmi';
import LoginButton from '../components/LoginButton';
import SignupButton from '../components/SignupButton';
import WalletWrapper from 'src/components/WalletWrapper';

export default function Page() {
const { address } = useAccount();
const { isConnected } = useAccount();

return (
<div className='flex h-full w-96 max-w-full flex-col px-1 font-sans md:w-[1008px]'>
Expand All @@ -23,15 +22,18 @@ export default function Page() {
<OnchainkitSvg />
</a>
<div className="flex items-center gap-3">
<SignupButton />
{!address && <LoginButton />}
<WalletWrapper />
</div>
</div>
</section>
<section className="templateSection flex w-full flex-col items-center justify-center gap-4 rounded-xl px-2 py-4 md:grow">
<div className="flex h-[450px] w-[450px] max-w-full items-center justify-center rounded-xl bg-[#140431]">
<section className="flex w-full flex-col items-center justify-center gap-4 rounded-xl px-2 py-4 md:grow">
{isConnected ? (
<IdentityWrapper />
</div>
) : (
<div className="flex h-48 w-full max-w-md items-center justify-center rounded-lg bg-gray-100 p-6 text-center text-gray-600">
Please connect your account to see your profile
</div>
)}
</section>
<Footer />
</div>
Expand Down
12 changes: 12 additions & 0 deletions src/components/FundComponent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { FundButton } from '@coinbase/onchainkit/fund';

export default function FundComponent() {

return <FundButton
className='bg-slate-300 font-sans text-black hover:bg-purple-500'
text={"Buy Crypto"}
hideText={false}
hideIcon={true}
openIn={"tab"}
/>;
}
163 changes: 8 additions & 155 deletions src/components/IdentityWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,162 +1,15 @@
'use client';

import { Avatar, Name } from '@coinbase/onchainkit/identity';
import { getName } from '@coinbase/onchainkit/identity';
import { Github, Globe, Twitter, ChevronDown } from 'lucide-react'; // Import ChevronDown
import { useEffect, useState } from 'react';
import { IdentityCard } from '@coinbase/onchainkit/identity';
import { base } from 'viem/chains';
import { normalize } from 'viem/ens';
import { useAccount } from 'wagmi';
import { publicClient } from '../client';
import { motion } from 'framer-motion'; // Import framer-motion
import { FarcasterSocialIcon } from '../svg/FarcasterIcon';


export default function IdentityWrapper() {
const { address } = useAccount();
const [ensText, setEnsText] = useState<{
twitter: string | null;
github: string | null;
farcaster: string | null;
url: string | null;
} | null>(null);
const [isOpen, setIsOpen] = useState(false); // State to manage dropdown visibility

useEffect(() => {

const fetchEnsText = async () => {

if (address) {
const cachedData = localStorage.getItem(address);
if (cachedData) {
setEnsText(JSON.parse(cachedData));
return;
}

try {

const name = await getName({ chain: base, address: address });
const normalizedAddress = normalize(name as string);

const twitterText = await publicClient.getEnsText({
name: normalizedAddress,
key: 'com.twitter',
});

const githubText = await publicClient.getEnsText({
name: normalizedAddress,
key: 'com.github',
});

const farcasterText = await publicClient.getEnsText({
name: normalizedAddress,
key: 'xyz.farcaster',
});

const urlText = await publicClient.getEnsText({
name: normalizedAddress,
key: 'url',
});


const fetchedData = {
twitter: twitterText,
github: githubText,
farcaster: farcasterText,
url: urlText,
};

setEnsText(fetchedData);
localStorage.setItem(address, JSON.stringify(fetchedData));
} catch (error) {
console.error('Error fetching ENS text:', error);
}
}
};
fetchEnsText();
}, [address]);

return (
<div className="mx-auto max-w-2xl p-4">
{address ? (
<motion.div
className="relative space-y-2"
initial={{ opacity: 0, y: -20 }} // Initial state
animate={{ opacity: 1, y: 0 }} // Animated state
transition={{ duration: 0.5 }} // Animation duration
>

{/* biome-ignore lint/a11y/useKeyWithClickEvents: <explanation> */}
<div className='flex cursor-pointer items-center justify-between space-x-2 rounded-full bg-white bg-opacity-20 p-2 transition-all duration-300 hover:bg-opacity-30' onClick={() => setIsOpen(!isOpen)}>
<div className='flex items-center space-x-2'>
<Avatar address={address} chain={base} />
<Name address={address} chain={base} className="text-m text-white" />
</div>
<ChevronDown className={`h-4 w-4 text-white transition-transform ${isOpen ? 'rotate-180' : ''}`} /> {/* Dropdown arrow */}
</div>
{ensText && (
<motion.div
className='rounded-lg bg-white bg-opacity-20 p-4 text-white shadow-md'
initial={{ height: 0, opacity: 0 }} // Initial state
animate={{ height: isOpen ? 'auto' : 0, opacity: isOpen ? 1 : 0 }} // Animated state
transition={{ duration: 0.5, ease: "easeInOut" }} // Animation duration and easing
style={{ overflow: 'hidden' }} // Ensure smooth height transition
>
<div className="flex items-center space-x-2">
<Twitter className="h-4 w-4" />
<span>Twitter:</span>
<a
href={`https://x.com/${ensText.twitter}`}
target="_blank"
rel="noopener noreferrer"
className="hover:underline"
>
{ensText.twitter}
</a>
</div>
<div className="mt-2 flex items-center space-x-2">
<FarcasterSocialIcon className="h-4 w-4" />
<span>Farcaster:</span>
<a
href={`https://warpcast.com/${ensText.farcaster}`}
target="_blank"
rel="noopener noreferrer"
className="hover:underline"
>
{ensText.farcaster}
</a>
</div>
<div className='mt-2 flex items-center space-x-2'>
<Github className='h-4 w-4' />
<span>Github:</span>
<a
href={`https://github.com/${ensText.github}`}
target="_blank"
rel="noopener noreferrer"
className="hover:underline"
>
{ensText.github}
</a>
</div>
<div className='mt-2 flex items-center space-x-2'>
<Globe className="h-4 w-4" />
<span>Website:</span>
<a
href={ensText.url ?? ''}
target="_blank"
rel="noopener noreferrer"
className="hover:underline"
>
{ensText.url?.replace(/^https?:\/\//, '')}
</a>
</div>
</motion.div>
)}
</motion.div>
) : (
<div className='text-center text-white'>
Connect your wallet to view your profile card.
</div>
)}
</div>
<IdentityCard
address={address}
schemaId={address}
chain={base}
/>
);
}
}
43 changes: 0 additions & 43 deletions src/components/LoginButton.test.tsx

This file was deleted.

12 changes: 0 additions & 12 deletions src/components/LoginButton.tsx

This file was deleted.

37 changes: 0 additions & 37 deletions src/components/OnchainProviders.test.tsx

This file was deleted.

8 changes: 7 additions & 1 deletion src/components/OnchainProviders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ function OnchainProviders({ children }: Props) {
return (
<WagmiProvider config={wagmiConfig}>
<QueryClientProvider client={queryClient}>
<OnchainKitProvider apiKey={NEXT_PUBLIC_CDP_API_KEY} chain={base}>
<OnchainKitProvider apiKey={NEXT_PUBLIC_CDP_API_KEY} chain={base}
config={{
appearance: {
mode: 'dark',
theme: 'default',
},
}}>
<RainbowKitProvider modalSize="compact">
{children}
</RainbowKitProvider>
Expand Down
Loading

0 comments on commit 044a6f3

Please sign in to comment.