Skip to content

Commit 4b16d3f

Browse files
committed
refactor: livedatawrapper styles
1 parent cea1a09 commit 4b16d3f

File tree

4 files changed

+72
-21
lines changed

4 files changed

+72
-21
lines changed

app/globals.css

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,55 @@
765765
}
766766
}
767767

768+
/* LiveDataWrapper Component Utilities */
769+
#live-data-wrapper {
770+
@apply size-full xl:col-span-2;
771+
772+
.divider {
773+
@apply my-8! bg-purple-600!;
774+
}
775+
776+
.trend {
777+
@apply w-full;
778+
779+
h4 {
780+
@apply text-xl md:text-2xl font-semibold mb-2 mt-2 pl-2;
781+
}
782+
}
783+
784+
.trades {
785+
@apply w-full my-8 space-y-4;
786+
787+
h4 {
788+
@apply text-xl md:text-2xl font-semibold mb-2;
789+
}
790+
}
791+
792+
.trades-table {
793+
@apply bg-dark-500 mt-5 rounded-xl overflow-hidden;
794+
795+
.price-cell {
796+
@apply pl-5 py-5 font-medium;
797+
}
798+
799+
.amount-cell {
800+
@apply py-4 font-medium;
801+
}
802+
803+
.value-cell {
804+
@apply font-medium;
805+
}
806+
807+
.type-cell {
808+
@apply font-medium;
809+
}
810+
811+
.time-cell {
812+
@apply pr-5;
813+
}
814+
}
815+
}
816+
768817
.skeleton {
769818
@apply bg-dark-400/60;
770819
}

components/DataTable.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const DataTable = <T,>({
1717
headerRowClassName,
1818
headerCellClassName = 'text-purple-100',
1919
bodyRowClassName,
20+
bodyCellClassName,
2021
}: DataTableProps<T>) => {
2122
return (
2223
<Table className={cn('custom-scrollbar', tableClassName)}>
@@ -50,6 +51,7 @@ export const DataTable = <T,>({
5051
<TableCell
5152
key={columnIndex}
5253
className={cn(
54+
bodyCellClassName,
5355
column.cellClassName,
5456
columnIndex === 0 && 'pl-5',
5557
columnIndex === columns.length - 1 && 'pr-5'

components/LiveDataWrapper.tsx

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@ export default function LiveDataWrapper({
2222
const tradeColumns = [
2323
{
2424
header: 'Price',
25-
cellClassName: 'pl-5 py-5 font-medium',
25+
cellClassName: 'price-cell',
2626
cell: (trade: Trade) => (trade.price ? formatPrice(trade.price) : '-'),
2727
},
2828
{
2929
header: 'Amount',
30-
cellClassName: 'py-4 font-medium',
30+
cellClassName: 'amount-cell',
3131
cell: (trade: Trade) => trade.amount?.toFixed(4) ?? '-',
3232
},
3333
{
3434
header: 'Value',
35-
cellClassName: 'font-medium',
35+
cellClassName: 'value-cell',
3636
cell: (trade: Trade) => (trade.value ? formatPrice(trade.value) : '-'),
3737
},
3838
{
3939
header: 'Buy/Sell',
40-
cellClassName: 'font-medium',
40+
cellClassName: 'type-cell',
4141
cell: (trade: Trade) => (
4242
<span
4343
className={trade.type === 'b' ? 'text-green-500' : 'text-red-500'}
@@ -48,14 +48,14 @@ export default function LiveDataWrapper({
4848
},
4949
{
5050
header: 'Time',
51-
cellClassName: 'pr-5',
51+
cellClassName: 'time-cell',
5252
cell: (trade: Trade) =>
5353
trade.timestamp ? timeAgo(trade.timestamp) : '-',
5454
},
5555
];
5656

5757
return (
58-
<section className='size-full xl:col-span-2'>
58+
<section id='live-data-wrapper'>
5959
<CoinHeader
6060
name={coin.name}
6161
image={coin.image.large}
@@ -70,33 +70,32 @@ export default function LiveDataWrapper({
7070
priceChange24h={coin.market_data.price_change_24h_in_currency.usd}
7171
/>
7272

73-
<Separator className='my-8 bg-purple-600' />
73+
<Separator className='divider' />
7474

75-
{/* Trend Overview */}
76-
<div className='w-full'>
75+
<div className='trend'>
7776
<CandlestickChart
7877
data={coinOHLCData}
7978
liveOhlcv={ohlcv}
8079
coinId={coinId}
8180
mode='live'
8281
initialPeriod='daily'
8382
>
84-
<h4 className='section-title mt-2 pl-2'>Trend Overview</h4>
83+
<h4>Trend Overview</h4>
8584
</CandlestickChart>
8685
</div>
8786

88-
<Separator className='my-8 bg-purple-600' />
87+
<Separator className='divider' />
8988

90-
{/* Recent Trades */}
91-
<div className='w-full my-8 space-y-4'>
92-
<h4 className='section-title'>Recent Trades</h4>
93-
<div className='custom-scrollbar bg-dark-500 mt-5 rounded-xl overflow-hidden'>
94-
<DataTable
95-
columns={tradeColumns}
96-
data={trades ?? []}
97-
rowKey={(_, index) => index}
98-
/>
99-
</div>
89+
<div className='trades'>
90+
<h4>Recent Trades</h4>
91+
<DataTable
92+
tableClassName='trades-table'
93+
columns={tradeColumns}
94+
data={trades ?? []}
95+
rowKey={(_, index) => index}
96+
headerCellClassName='py-5! text-purple-100!'
97+
bodyCellClassName='py-5!'
98+
/>
10099
</div>
101100

102101
{children}

types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ interface DataTableProps<T> {
269269
headerRowClassName?: string;
270270
headerCellClassName?: string;
271271
bodyRowClassName?: string;
272+
bodyCellClassName?: string;
272273
}
273274

274275
type ButtonSize = 'default' | 'sm' | 'lg' | 'icon' | 'icon-sm' | 'icon-lg';

0 commit comments

Comments
 (0)