Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update nft images #40

Merged
merged 3 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions app/components/Agent.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { useState } from 'react';
import AgentAssets from './AgentAssets';
import AgentBalance from './AgentBalance';
import AgentProfile from './AgentProfile';
import Chat from './Chat';
import Footer from './Footer';
import Navbar from './Navbar';
import Stream from './Stream';

Expand All @@ -28,9 +26,7 @@ export default function Agent() {
} fixed z-20 flex h-full w-full flex-col overflow-y-auto bg-black transition-transform duration-300 lg:relative lg:z-0 lg:w-1/3 lg:translate-x-0 lg:border-[#5788FA]/50 lg:border-r `}
>
<AgentProfile />
<AgentBalance />
<AgentAssets />
<Footer />
</div>

<div className="flex w-full lg:w-2/3">
Expand All @@ -47,9 +43,6 @@ export default function Agent() {
<Stream className="flex w-full flex-col" />
</div>
</div>
<div className="z-20 lg:hidden">
<Footer />
</div>
</div>
);
}
21 changes: 14 additions & 7 deletions app/components/AgentAssets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import useGetTokens from '../hooks/useGetTokens';

type AgentAssetProps = {
tokenAddress: Address;
index?: number;
};

function AgentToken({ tokenAddress }: AgentAssetProps) {
Expand All @@ -26,7 +27,7 @@ function AgentToken({ tokenAddress }: AgentAssetProps) {
return <TokenRow token={token} className="max-w-56 rounded font-mono" />;
}

function AgentNFT({ tokenAddress }: AgentAssetProps) {
function AgentNFT({ index = 0, tokenAddress }: AgentAssetProps) {
const { data: name } = useContractRead({
address: tokenAddress,
abi: erc721Abi,
Expand All @@ -37,15 +38,20 @@ function AgentNFT({ tokenAddress }: AgentAssetProps) {
const nftData = useMemo(() => {
return {
name,
imageUrl: `https://raw.githubusercontent.com/coinbase/onchain-agent-demo/master/app/images/${(index + 1) % 8}.png`,
};
}, [name]);
}, [name, index]);

if (!name) {
return null;
}

return (
<NFTMintCard contractAddress={tokenAddress} useNFTData={() => nftData}>
<NFTMintCard
className="max-w-72"
contractAddress={tokenAddress}
useNFTData={() => nftData}
>
<NFTMedia />
<NFTCollectionTitle className="font-mono text-sm" />
</NFTMintCard>
Expand All @@ -69,9 +75,10 @@ export default function AgentAssets() {
}, [getNFTs, getTokens]);

return (
<div className="mr-2 mb-4 rounded-sm bg-black p-4">
<div className="mr-2 mb-4 w-full rounded-sm border-[#5788FA]/50 border-t bg-black p-4 pb-10 lg:relative lg:z-0 lg:translate-x-0">
<h2 className="pb-4 font-bold text-[#5788FA] text-xl">My creations</h2>
<div className="flex flex-col items-start gap-4">
<div className="flex w-full grow gap-6 border-zinc-700 border-b">
<div className="flex w-full grow gap-6 border-[#5788FA]/50 border-b">
<button
type="button"
onClick={handleTabChange('nfts')}
Expand Down Expand Up @@ -100,8 +107,8 @@ export default function AgentAssets() {

{tab === 'nfts' && nfts && (
<div className="grid-col-1 grid gap-4 sm:grid-cols-2">
{nfts?.map((nft) => (
<AgentNFT key={nft} tokenAddress={nft} />
{nfts?.map((nft, index) => (
<AgentNFT key={nft} tokenAddress={nft} index={index} />
))}
</div>
)}
Expand Down
14 changes: 8 additions & 6 deletions app/components/AgentBalance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ export default function AgentBalance() {
query: { refetchInterval: 5000 },
});

if (!data) {
return null;
}

return (
<div className="rounded-sm border-zinc-700 border-t bg-black p-4 pt-8">
<div className="flex flex-col items-start ">
<span className="font-bold text-3xl text-[#5788FA]">
{`${Number.parseFloat(data?.formatted || '').toFixed(6)} ETH`}
</span>
</div>
<div className="rounded-sm border-zinc-700">
<span className="text-[#5788FA] text-base">
{`${Number.parseFloat(data?.formatted || '').toFixed(6)} ETH`}
</span>
</div>
);
}
12 changes: 8 additions & 4 deletions app/components/AgentProfile.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { AGENT_NAME, AGENT_WALLET_ADDRESS } from '../constants';
import AgentBalance from './AgentBalance';

export default function AgentProfile() {
const [eyePosition, setEyePosition] = useState({ x: 50, y: 50 });
Expand Down Expand Up @@ -75,12 +76,12 @@ export default function AgentProfile() {
</svg>

<div className="flex flex-col justify-center space-y-2">
<h2 className="font-bold text-[#5788FA] text-xl">{AGENT_NAME}</h2>
<div className="group relative inline-flex items-center">
<div className="flex items-center justify-center gap-2">
<h2 className="font-bold text-[#5788FA] text-xl">{AGENT_NAME}</h2>
<button
type="button"
onClick={copyToClipboard}
className="text-[#5788FA] text-sm transition-colors hover:text-[#3D7BFF]"
className="rounded-sm bg-blue-900 bg-opacity-30 p-1 px-2 text-[#5788FA] text-sm transition-colors hover:text-[#3D7BFF]"
>
{formattedAddress}
</button>
Expand All @@ -90,11 +91,14 @@ export default function AgentProfile() {
</div>
)}
</div>
<div className="group relative inline-flex items-center">
<AgentBalance />
</div>
</div>
</div>

<p className="text-[#5788FA] text-base">
{`I'm your onchain concierge`}
I observe, imagine, and create onchain.
</p>
</div>
</div>
Expand Down
8 changes: 7 additions & 1 deletion app/components/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ export default function Chat({ className }: ChatProps) {
const bottomRef = useRef<HTMLDivElement>(null);

const handleSuccess = useCallback((messages: AgentMessage[]) => {
const message = messages.find((res) => res.event === 'agent');
let message = messages.find((res) => res.event === 'agent');
if (!message) {
message = messages.find((res) => res.event === 'tools');
}
if (!message) {
message = messages.find((res) => res.event === 'error');
}
const streamEntry: StreamEntry = {
timestamp: new Date(),
content: markdownToPlainText(message?.data || ''),
Expand Down
67 changes: 47 additions & 20 deletions app/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,28 +73,55 @@ export default function Navbar({
</button>
</div>
<div className="flex w-full justify-between p-2">
<div className="flex items-center space-x-2">
<button
className="mr-2 hidden md:flex lg:hidden"
onClick={handleMobileProfileClick}
type="button"
>
</button>
<div
className={`h-2 w-2 rounded-full transition-all duration-700 ease-in-out ${
isLiveDotVisible
? 'bg-green-500 opacity-100'
: 'bg-green-500 opacity-40'
}
<div className="flex items-center gap-4">
<div className="flex items-center space-x-2">
<button
className="mr-2 hidden md:flex lg:hidden"
onClick={handleMobileProfileClick}
type="button"
>
</button>
<div
className={`h-2 w-2 rounded-full transition-all duration-700 ease-in-out ${
isLiveDotVisible
? 'bg-green-500 opacity-100'
: 'bg-green-500 opacity-40'
}
`}
/>
<span className="text-xs text-zinc-50 sm:text-sm">
Live on Base Sepolia
</span>
/>
<span className="text-xs text-zinc-50 sm:text-sm">
Live on Base Sepolia
</span>
</div>
<div
className="hidden text-xs text-zinc-400 sm:text-sm md:flex"
aria-live="polite"
>
{formatDateToBangkokTime(new Date())} ICT
</div>
</div>
<div className="text-xs sm:text-sm" aria-live="polite">
{formatDateToBangkokTime(new Date())} ICT
<div className="flex bg-black text-sm text-xs text-zinc-400 sm:text-sm ">
<div className="hidden sm:flex">
<span className="pr-1">Powered by</span>
<a
href="https://onchainkit.xyz/"
target="_blank"
rel="noopener noreferrer"
className="font-bold transition-colors hover:text-zinc-300"
>
OnchainKit
</a>
<span className="mx-2">·</span>
</div>
<a
href="https://github.com/coinbase/onchain-agent-demo"
target="_blank"
rel="noopener noreferrer"
className="transition-colors hover:text-zinc-300"
>
Fork this template
</a>
</div>
</div>
</div>
Expand Down
10 changes: 8 additions & 2 deletions app/components/Stream.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ export default function Stream({ className }: StreamProps) {
}, []);

const handleSuccess = useCallback((messages: AgentMessage[]) => {
const message = messages.find((res) => res.event === 'agent');
let message = messages.find((res) => res.event === 'agent');
if (!message) {
message = messages.find((res) => res.event === 'tools');
}
if (!message) {
message = messages.find((res) => res.event === 'error');
}
const streamEntry: StreamEntry = {
timestamp: new Date(),
content: markdownToPlainText(message?.data || ''),
Expand All @@ -45,7 +51,7 @@ export default function Stream({ className }: StreamProps) {
if (!isLoading) {
postChat(DEFAULT_PROMPT);
}
}, 1500);
}, 6000);

return () => {
clearInterval(streamInterval);
Expand Down
2 changes: 1 addition & 1 deletion app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ export type AnimatedData = {

export type AgentMessage = {
data?: string;
event: 'agent' | 'tools' | 'completed';
event: 'agent' | 'tools' | 'completed' | 'error';
};