Skip to content

Commit 3525d0b

Browse files
committed
refactor: coinheader styles
1 parent d2de97f commit 3525d0b

File tree

2 files changed

+74
-90
lines changed

2 files changed

+74
-90
lines changed

app/globals.css

Lines changed: 56 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,18 @@
159159
@apply !bg-dark-500;
160160
}
161161

162+
.badge {
163+
@apply font-medium mt-2 h-fit py-1 flex items-center gap-1;
164+
}
165+
166+
.badge-up {
167+
@apply bg-green-600/20! text-green-600!;
168+
}
169+
170+
.badge-down {
171+
@apply bg-red-500/20! text-red-500!;
172+
}
173+
162174
/* CandlestickChart Styles */
163175
#candlestick-chart {
164176
@apply p-3 mt-5 rounded-lg bg-dark-500;
@@ -213,18 +225,6 @@
213225

214226
.change {
215227
@apply flex items-center gap-2;
216-
217-
.badge {
218-
@apply font-medium! h-fit! py-1! flex! items-center! gap-1!;
219-
}
220-
221-
.badge-up {
222-
@apply bg-green-600/20! text-green-600!;
223-
}
224-
225-
.badge-down {
226-
@apply bg-red-500/20! text-red-500!;
227-
}
228228
}
229229
}
230230

@@ -628,65 +628,44 @@
628628
}
629629

630630
/* CoinHeader Component Utilities */
631-
.coin-header-container {
631+
#coin-header {
632632
@apply space-y-5 w-full;
633-
}
634-
635-
.coin-header-info {
636-
@apply flex gap-3 items-center;
637-
}
638633

639-
.coin-header-image {
640-
@apply size-[45px] sm:size-[50px] xl:size-[77px];
641-
}
642-
643-
.coin-header-price {
644-
@apply text-3xl sm:text-5xl xl:text-6xl font-semibold;
645-
}
646-
647-
.coin-header-badge {
648-
@apply font-medium mt-2 h-fit py-1 flex items-center gap-1;
649-
}
650-
651-
.coin-header-stats {
652-
@apply grid grid-cols-3 mt-8 gap-4 sm:gap-6 w-fit;
653-
}
654-
655-
.coin-header-stat {
656-
@apply text-base border-r border-purple-600 flex flex-col gap-2;
657-
}
634+
h3 {
635+
@apply text-3xl font-medium;
636+
}
658637

659-
.coin-header-stat-label {
660-
@apply text-purple-100 max-sm:text-sm;
661-
}
638+
.info {
639+
@apply flex gap-3 items-center;
662640

663-
.coin-header-stat-value {
664-
@apply flex flex-1 gap-1 items-end text-base font-medium;
665-
}
641+
img {
642+
@apply size-[45px] sm:size-[50px] xl:size-[77px];
643+
}
644+
}
666645

667-
.coin-header-stat-value-30d {
668-
@apply flex gap-1 flex-1 items-end text-base font-medium;
669-
}
646+
.price-row {
647+
@apply flex gap-4;
670648

671-
.coin-header-stat-price {
672-
@apply flex gap-1 items-center text-base font-medium;
673-
}
649+
h1 {
650+
@apply text-3xl sm:text-5xl xl:text-6xl font-semibold;
651+
}
652+
}
674653

675-
/* Skeleton States */
676-
.coin-header-skeleton-image {
677-
@apply size-[45px] sm:size-[50px] xl:size-[77px] bg-dark-400/50 rounded-full animate-pulse;
678-
}
654+
.stats {
655+
@apply grid grid-cols-3 mt-8 gap-4 sm:gap-6 w-fit;
679656

680-
.coin-header-skeleton-price {
681-
@apply h-12 sm:h-16 xl:h-20 w-48 sm:w-64 xl:w-80 bg-dark-400/50 rounded animate-pulse;
682-
}
657+
li {
658+
@apply text-base border-r last:border-none border-purple-600 flex flex-col gap-2;
683659

684-
.coin-header-skeleton-badge {
685-
@apply h-10 w-32 bg-dark-400/50 rounded-full animate-pulse mt-2;
686-
}
660+
.label {
661+
@apply text-purple-100 max-sm:text-sm;
662+
}
687663

688-
.coin-header-skeleton-stat {
689-
@apply h-5 w-24 bg-dark-400/50 rounded animate-pulse;
664+
.value {
665+
@apply flex gap-1 flex-1 items-end text-base font-medium;
666+
}
667+
}
668+
}
690669
}
691670

692671
/* CoinOverview Component Utilities */
@@ -717,6 +696,22 @@
717696
.skeleton {
718697
@apply bg-dark-400/60;
719698
}
699+
700+
.skeleton-image {
701+
@apply size-[45px] sm:size-[50px] xl:size-[77px] bg-dark-400/50 rounded-full animate-pulse;
702+
}
703+
704+
.skeleton-price {
705+
@apply h-12 sm:h-16 xl:h-20 w-48 sm:w-64 xl:w-80 bg-dark-400/50 rounded animate-pulse;
706+
}
707+
708+
.skeleton-badge {
709+
@apply h-10 w-32 bg-dark-400/50 rounded-full animate-pulse mt-2;
710+
}
711+
712+
.skeleton-stat {
713+
@apply h-5 w-24 bg-dark-400/50 rounded animate-pulse;
714+
}
720715
}
721716

722717
/* Custom Scrollbar Styles */

components/CoinHeader.tsx

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
'use client';
22

3-
import { cn, formatPercentage, formatPrice } from '@/lib/utils';
4-
import { TrendingDown, TrendingUp } from 'lucide-react';
53
import Image from 'next/image';
4+
import { TrendingDown, TrendingUp } from 'lucide-react';
5+
66
import { Badge } from './ui/badge';
7+
import { cn, formatPercentage, formatPrice } from '@/lib/utils';
78

89
export default function CoinHeader({
910
livePriceChangePercentage24h,
@@ -23,48 +24,35 @@ export default function CoinHeader({
2324
value: livePriceChangePercentage24h,
2425
isUp: isTrendingUp,
2526
formatter: formatPercentage,
26-
valueClassName: 'coin-header-stat-value',
2727
showIcon: true,
2828
},
2929
{
3030
label: '30 Days',
3131
value: priceChangePercentage30d,
3232
isUp: isThirtyDayUp,
3333
formatter: formatPercentage,
34-
valueClassName: 'coin-header-stat-value-30d',
3534
showIcon: true,
3635
},
3736
{
3837
label: 'Price Change (24h)',
3938
value: priceChange24h,
4039
isUp: isPriceChangeUp,
4140
formatter: formatPrice,
42-
valueClassName: 'coin-header-stat-price',
4341
showIcon: false,
4442
},
4543
];
4644

4745
return (
48-
<div className='coin-header-container'>
49-
<h3 className='text-3xl font-medium'>{name}</h3>
46+
<div id='coin-header'>
47+
<h3>{name}</h3>
48+
49+
<div className='info'>
50+
<Image src={image} alt={name} width={77} height={77} />
5051

51-
<div className='coin-header-info'>
52-
<Image
53-
src={image}
54-
alt={name}
55-
width={77}
56-
height={77}
57-
className='coin-header-image'
58-
/>
59-
<div className='flex gap-4'>
60-
<h1 className='coin-header-price'>{formatPrice(livePrice)}</h1>
52+
<div className='price-row'>
53+
<h1>{formatPrice(livePrice)}</h1>
6154
<Badge
62-
className={cn(
63-
'coin-header-badge',
64-
isTrendingUp
65-
? 'bg-green-600/20 text-green-600'
66-
: 'bg-red-500/20 text-red-500'
67-
)}
55+
className={cn('badge', isTrendingUp ? 'badge-up' : 'badge-down')}
6856
>
6957
{formatPercentage(livePriceChangePercentage24h)}
7058
{isTrendingUp ? <TrendingUp /> : <TrendingDown />}
@@ -73,12 +61,13 @@ export default function CoinHeader({
7361
</div>
7462
</div>
7563

76-
<div className='coin-header-stats'>
64+
<ul className='stats'>
7765
{stats.map((stat) => (
78-
<div key={stat.label} className='coin-header-stat'>
79-
<p className='coin-header-stat-label'>{stat.label}</p>
66+
<li key={stat.label}>
67+
<p className='label'>{stat.label}</p>
68+
8069
<div
81-
className={cn(stat.valueClassName, {
70+
className={cn('value', {
8271
'text-green-500': stat.isUp,
8372
'text-red-500': !stat.isUp,
8473
})}
@@ -91,9 +80,9 @@ export default function CoinHeader({
9180
<TrendingDown width={16} height={16} />
9281
))}
9382
</div>
94-
</div>
83+
</li>
9584
))}
96-
</div>
85+
</ul>
9786
</div>
9887
);
9988
}

0 commit comments

Comments
 (0)