Skip to content

Commit 14c503a

Browse files
committed
fix
1 parent 2474a6e commit 14c503a

File tree

2 files changed

+96
-8
lines changed

2 files changed

+96
-8
lines changed

app/coins/[id]/page.tsx

Lines changed: 92 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import { Badge } from '@/components/ui/badge';
12
import { Separator } from '@/components/ui/separator';
23
import { getCoinDetails, getCoinOHLC } from '@/lib/ coingecko.actions';
3-
import { formatPrice, timeAgo } from '@/lib/utils';
4-
import { ArrowUpRight } from 'lucide-react';
4+
import { cn, formatPercentage, formatPrice, timeAgo } from '@/lib/utils';
5+
import { ArrowUpRight, TrendingDown, TrendingUp } from 'lucide-react';
56

7+
import Image from 'next/image';
68
import Link from 'next/link';
79
import {
810
Table,
@@ -44,11 +46,97 @@ const CoinDetails = async ({ params }: { params: Promise<{ id: string }> }) => {
4446
tickers: coinData.tickers,
4547
};
4648

49+
const isTrendingUp = coin.priceChangePercentage24h > 0;
50+
4751
return (
4852
<main className='py-12 container size-full grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 items-center gap-6 xl:gap-10 justify-center'>
4953
<section className='size-full xl:col-span-2'>
50-
{/* Coin Details - Live */}
51-
<LiveCoinHeader coinId={coin.id} name={coin.name} image={coin.image} />
54+
{/* Coin Details */}
55+
<div className='space-y-5 w-full'>
56+
<h3 className='text-3xl font-medium'>{coin.name}</h3>
57+
<div className='flex gap-3 items-center'>
58+
<Image
59+
src={coin.image}
60+
alt={coin.name}
61+
width={77}
62+
height={77}
63+
className='size-[45px] sm:size-[50px] xl:size-[77px]'
64+
/>
65+
<div className='flex gap-4'>
66+
<h1 className='text-3xl sm:text-5xl xl:text-6xl font-semibold'>
67+
{formatPrice(coin.price)}
68+
</h1>
69+
<Badge
70+
className={cn(
71+
'font-medium mt-2 h-fit py-1 flex items-center gap-1',
72+
isTrendingUp
73+
? 'bg-green-500/20 text-green-600'
74+
: 'bg-red-500/20 text-red-500'
75+
)}
76+
>
77+
{formatPercentage(coin.priceChangePercentage24h)}
78+
{isTrendingUp ? <TrendingUp /> : <TrendingDown />}
79+
(24h)
80+
</Badge>
81+
</div>
82+
</div>
83+
<div className='grid grid-cols-3 mt-8 gap-4 sm:gap-6 w-fit'>
84+
{/* Today */}
85+
<div className='text-base border-r border-purple-600 flex flex-col gap-2'>
86+
<p className='text-purple-100 max-sm:text-sm'>Today</p>
87+
<div
88+
className={cn(
89+
'flex flex-1 gap-1 items-end text-sm font-medium',
90+
{
91+
'text-green-500': coin.priceChangePercentage24h > 0,
92+
'text-red-500': coin.priceChangePercentage24h < 0,
93+
}
94+
)}
95+
>
96+
<p>{formatPercentage(coin.priceChangePercentage24h)}</p>
97+
{isTrendingUp ? (
98+
<TrendingUp width={16} height={16} />
99+
) : (
100+
<TrendingDown width={16} height={16} />
101+
)}
102+
</div>
103+
</div>
104+
{/* 30 Days */}
105+
<div className='text-base border-r border-purple-600 flex flex-col gap-2'>
106+
<p className='text-purple-100 max-sm:text-sm'>30 Days</p>
107+
<div
108+
className={cn(
109+
'flex gap-1 flex-1 items-end text-sm font-medium',
110+
{
111+
'text-green-500': coin.priceChangePercentage30d > 0,
112+
'text-red-500': coin.priceChangePercentage30d < 0,
113+
}
114+
)}
115+
>
116+
<p>{formatPercentage(coin.priceChangePercentage30d)}</p>
117+
{isTrendingUp ? (
118+
<TrendingUp width={16} height={16} />
119+
) : (
120+
<TrendingDown width={16} height={16} />
121+
)}
122+
</div>
123+
</div>
124+
{/* Rank */}
125+
<div className='text-base flex flex-col gap-2'>
126+
<p className='text-purple-100 max-sm:text-sm'>
127+
Price Change (24h)
128+
</p>
129+
<p
130+
className={cn('flex gap-1 items-center text-sm font-medium', {
131+
'text-green-500': coin.priceChange24h > 0,
132+
'text-red-500': coin.priceChange24h < 0,
133+
})}
134+
>
135+
{formatPrice(coin.priceChange24h)}
136+
</p>
137+
</div>
138+
</div>
139+
</div>
52140

53141
<Separator className='my-8 bg-purple-600' />
54142

app/page.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import {
1717
} from '@/components/ui/table';
1818

1919
import ChartSection from '@/components/ChartSection';
20-
import CoinCard from '@/components/CoinCard';
21-
import { popularCoins } from '@/lib/constants';
20+
// import CoinCard from '@/components/CoinCard';
21+
// import { popularCoins } from '@/lib/constants';
2222
import { TrendingDown, TrendingUp } from 'lucide-react';
2323

2424
const Home = async () => {
@@ -123,7 +123,7 @@ const Home = async () => {
123123
</div>
124124
</section>
125125

126-
<section className='w-full grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 md:gap-6'>
126+
{/* <section className='w-full grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 md:gap-6'>
127127
{popularCoins.map((coin) => (
128128
<CoinCard
129129
key={coin.coinId}
@@ -133,7 +133,7 @@ const Home = async () => {
133133
image={coin.image}
134134
/>
135135
))}
136-
</section>
136+
</section> */}
137137
</main>
138138
);
139139
};

0 commit comments

Comments
 (0)