1+ import { TrendingDown , TrendingUp } from 'lucide-react' ;
2+ import Image from 'next/image' ;
3+
14import { DataTable } from '@/components/DataTable' ;
25import { getCategories } from '@/lib/coingecko.actions' ;
36import { cn , formatPercentage , formatPrice } from '@/lib/utils' ;
4- import { TrendingDown , TrendingUp } from 'lucide-react' ;
5- import Image from 'next/image' ;
67
78export const Categories = async ( ) => {
89 const categories = ( await getCategories ( ) ) as Category [ ] ;
910 const columns = [
1011 {
1112 header : 'Category' ,
12- cellClassName : 'pl-5 font-bold ' ,
13+ cellClassName : 'category-cell ' ,
1314 cell : ( category : Category ) => category . name ,
1415 } ,
1516 {
1617 header : 'Top Gainers' ,
17- cellClassName : 'flex gap-1 mr-5 ' ,
18+ cellClassName : 'top-gainers-cell ' ,
1819 cell : ( category : Category ) =>
1920 category . top_3_coins . map ( ( coin : string ) => (
2021 < Image
@@ -23,25 +24,21 @@ export const Categories = async () => {
2324 alt = 'Coin image'
2425 width = { 28 }
2526 height = { 28 }
26- className = 'rounded-full py-2'
2727 />
2828 ) ) ,
2929 } ,
3030 {
3131 header : '24h Change' ,
32- cellClassName : 'font-medium ' ,
32+ cellClassName : 'change-header-cell ' ,
3333 cell : ( category : Category ) => {
3434 const isTrendingUp = category . market_cap_change_24h > 0 ;
3535
3636 return (
3737 < div
38- className = { cn (
39- 'flex flex-1 gap-1 items-end pl-5 text-base font-medium' ,
40- {
41- 'text-green-500' : category . market_cap_change_24h > 0 ,
42- 'text-red-500' : category . market_cap_change_24h < 0 ,
43- }
44- ) }
38+ className = { cn ( 'change-cell' , {
39+ 'text-green-500' : category . market_cap_change_24h > 0 ,
40+ 'text-red-500' : category . market_cap_change_24h < 0 ,
41+ } ) }
4542 >
4643 < p > { formatPercentage ( category . market_cap_change_24h ) } </ p >
4744 { isTrendingUp ? (
@@ -55,19 +52,19 @@ export const Categories = async () => {
5552 } ,
5653 {
5754 header : 'Market Cap' ,
58- cellClassName : 'font-medium ' ,
55+ cellClassName : 'market-cap-cell ' ,
5956 cell : ( category : Category ) => formatPrice ( category . market_cap ) ,
6057 } ,
6158 {
6259 header : '24h Volume' ,
63- cellClassName : 'font-medium ' ,
60+ cellClassName : 'volume-cell ' ,
6461 cell : ( category : Category ) => formatPrice ( category . volume_24h ) ,
6562 } ,
6663 ] ;
6764
6865 return (
69- < div className = 'custom-scrollbar pt-8 mt-5 w-full bg-dark-500 rounded-xl overflow-hidden ' >
70- < h4 className = 'section-title pl-5' > Top Categories</ h4 >
66+ < div id = 'categories' className = 'custom-scrollbar' >
67+ < h4 > Top Categories</ h4 >
7168 < DataTable
7269 columns = { columns }
7370 data = { categories }
0 commit comments