1- import { Badge } from '@/components/ui/badge' ;
21import { Separator } from '@/components/ui/separator' ;
32import { getCoinDetails , getCoinOHLC } from '@/lib/ coingecko.actions' ;
4- import { cn , formatPercentage , formatPrice , timeAgo } from '@/lib/utils' ;
5- import { ArrowUpRight , TrendingDown , TrendingUp } from 'lucide-react' ;
3+ import { formatPrice , timeAgo } from '@/lib/utils' ;
4+ import { ArrowUpRight } from 'lucide-react' ;
65
7- import Image from 'next/image' ;
86import Link from 'next/link' ;
97import {
108 Table ,
@@ -16,6 +14,7 @@ import {
1614} from '@/components/ui/table' ;
1715import { Converter } from '@/components/Converter' ;
1816import CandlestickChart from '@/components/CandlestickChart' ;
17+ import LiveCoinHeader from '@/components/LiveCoinHeader' ;
1918
2019const CoinDetails = async ( { params } : { params : Promise < { id : string } > } ) => {
2120 const { id } = await params ;
@@ -45,97 +44,11 @@ const CoinDetails = async ({ params }: { params: Promise<{ id: string }> }) => {
4544 tickers : coinData . tickers ,
4645 } ;
4746
48- const isTrendingUp = coin . priceChangePercentage24h > 0 ;
49-
5047 return (
5148 < 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' >
5249 < section className = 'size-full xl:col-span-2' >
53- { /* Coin Details */ }
54- < div className = 'space-y-5 w-full' >
55- < h3 className = 'text-3xl font-medium' > { coin . name } </ h3 >
56- < div className = 'flex gap-3 items-center' >
57- < Image
58- src = { coin . image }
59- alt = { coin . name }
60- width = { 77 }
61- height = { 77 }
62- className = 'size-[45px] sm:size-[50px] xl:size-[77px]'
63- />
64- < div className = 'flex gap-4' >
65- < h1 className = 'text-3xl sm:text-5xl xl:text-6xl font-semibold' >
66- { formatPrice ( coin . price ) }
67- </ h1 >
68- < Badge
69- className = { cn (
70- 'font-medium mt-2 h-fit py-1 flex items-center gap-1' ,
71- isTrendingUp
72- ? 'bg-green-500/20 text-green-600'
73- : 'bg-red-500/20 text-red-500'
74- ) }
75- >
76- { formatPercentage ( coin . priceChangePercentage24h ) }
77- { isTrendingUp ? < TrendingUp /> : < TrendingDown /> }
78- (24h)
79- </ Badge >
80- </ div >
81- </ div >
82- < div className = 'grid grid-cols-3 mt-8 gap-4 sm:gap-6 w-fit' >
83- { /* Today */ }
84- < div className = 'text-base border-r border-purple-600 flex flex-col gap-2' >
85- < p className = 'text-purple-100 max-sm:text-sm' > Today</ p >
86- < div
87- className = { cn (
88- 'flex flex-1 gap-1 items-end text-sm font-medium' ,
89- {
90- 'text-green-500' : coin . priceChangePercentage24h > 0 ,
91- 'text-red-500' : coin . priceChangePercentage24h < 0 ,
92- }
93- ) }
94- >
95- < p > { formatPercentage ( coin . priceChangePercentage24h ) } </ p >
96- { isTrendingUp ? (
97- < TrendingUp width = { 16 } height = { 16 } />
98- ) : (
99- < TrendingDown width = { 16 } height = { 16 } />
100- ) }
101- </ div >
102- </ div >
103- { /* 30 Days */ }
104- < div className = 'text-base border-r border-purple-600 flex flex-col gap-2' >
105- < p className = 'text-purple-100 max-sm:text-sm' > 30 Days</ p >
106- < div
107- className = { cn (
108- 'flex gap-1 flex-1 items-end text-sm font-medium' ,
109- {
110- 'text-green-500' : coin . priceChangePercentage30d > 0 ,
111- 'text-red-500' : coin . priceChangePercentage30d < 0 ,
112- }
113- ) }
114- >
115- < p > { formatPercentage ( coin . priceChangePercentage30d ) } </ p >
116- { isTrendingUp ? (
117- < TrendingUp width = { 16 } height = { 16 } />
118- ) : (
119- < TrendingDown width = { 16 } height = { 16 } />
120- ) }
121- </ div >
122- </ div >
123- { /* Rank */ }
124- < div className = 'text-base flex flex-col gap-2' >
125- < p className = 'text-purple-100 max-sm:text-sm' >
126- Price Change (24h)
127- </ p >
128- < p
129- className = { cn ( 'flex gap-1 items-center text-sm font-medium' , {
130- 'text-green-500' : coin . priceChange24h > 0 ,
131- 'text-red-500' : coin . priceChange24h < 0 ,
132- } ) }
133- >
134- { formatPrice ( coin . priceChange24h ) }
135- </ p >
136- </ div >
137- </ div >
138- </ div >
50+ { /* Coin Details - Live */ }
51+ < LiveCoinHeader coinId = { coin . id } name = { coin . name } image = { coin . image } />
13952
14053 < Separator className = 'my-8 bg-purple-600' />
14154
0 commit comments