File size: 16,677 Bytes
57ef1ae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20242c6
 
 
 
57ef1ae
 
 
 
 
 
20242c6
 
57ef1ae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74105a9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CryptoPulse Tracker</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://unpkg.com/feather-icons"></script>
    <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: {
                            500: '#6366f1',
                        },
                        secondary: {
                            500: '#8b5cf6',
                        }
                    }
                }
            }
        }
    </script>
    <style>
        .crypto-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .price-up {
            color: #10b981;
        }
        .price-down {
            color: #ef4444;
        }
    </style>
</head>
<body class="bg-gray-50 min-h-screen">
    <div class="bg-primary-500 text-white">
        <div class="container mx-auto px-4 py-6">
            <header class="flex justify-between items-center">
                <div class="flex items-center space-x-2">
                    <i data-feather="activity" class="w-8 h-8"></i>
                    <h1 class="text-2xl font-bold">CryptoPulse Tracker</h1>
                </div>
                <div class="flex items-center space-x-4">
                    <button class="flex items-center space-x-1 bg-white bg-opacity-20 px-4 py-2 rounded-lg">
                        <i data-feather="refresh-cw" class="w-4 h-4"></i>
                        <span>Refresh</span>
                    </button>
                    <div class="relative">
                        <input type="text" placeholder="Search crypto..." class="bg-white bg-opacity-20 placeholder-white text-white rounded-lg px-4 py-2 pl-10 focus:outline-none focus:ring-2 focus:ring-white">
                        <i data-feather="search" class="absolute left-3 top-2.5 text-white w-4 h-4"></i>
                    </div>
                </div>
            </header>
        </div>
    </div>

    <main class="container mx-auto px-4 py-8">
        <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
            <!-- Market Overview Cards -->
            <div class="bg-white rounded-xl shadow-md p-6">
                <div class="flex justify-between items-center mb-4">
                    <h3 class="text-gray-500 font-medium">Market Cap</h3>
                    <i data-feather="dollar-sign" class="text-secondary-500"></i>
                </div>
                <div class="text-2xl font-bold">$1.23T</div>
                <div class="text-sm text-green-500 flex items-center mt-2">
                    <i data-feather="trending-up" class="w-4 h-4 mr-1"></i>
                    <span>2.34% (24h)</span>
                </div>
            </div>
            
            <div class="bg-white rounded-xl shadow-md p-6">
                <div class="flex justify-between items-center mb-4">
                    <h3 class="text-gray-500 font-medium">24h Volume</h3>
                    <i data-feather="bar-chart-2" class="text-secondary-500"></i>
                </div>
                <div class="text-2xl font-bold">$64.5B</div>
                <div class="text-sm text-red-500 flex items-center mt-2">
                    <i data-feather="trending-down" class="w-4 h-4 mr-1"></i>
                    <span>1.78% (24h)</span>
                </div>
            </div>
            
            <div class="bg-white rounded-xl shadow-md p-6">
                <div class="flex justify-between items-center mb-4">
                    <h3 class="text-gray-500 font-medium">BTC Dominance</h3>
                    <i data-feather="pie-chart" class="text-secondary-500"></i>
                </div>
                <div class="text-2xl font-bold">42.3%</div>
                <div class="text-sm text-green-500 flex items-center mt-2">
                    <i data-feather="trending-up" class="w-4 h-4 mr-1"></i>
                    <span>0.45% (24h)</span>
                </div>
            </div>
            
            <div class="bg-white rounded-xl shadow-md p-6">
                <div class="flex justify-between items-center mb-4">
                    <h3 class="text-gray-500 font-medium">Active Cryptos</h3>
                    <i data-feather="database" class="text-secondary-500"></i>
                </div>
                <div class="text-2xl font-bold">10,234</div>
                <div class="text-sm text-gray-500 mt-2">+124 new (7d)</div>
            </div>
        </div>

        <div class="bg-white rounded-xl shadow-md p-6 mb-8">
            <div class="flex justify-between items-center mb-6">
                <h2 class="text-xl font-bold">Market Trends</h2>
                <div class="flex space-x-2">
                    <button class="px-3 py-1 bg-primary-500 text-white rounded-lg text-sm">24h</button>
                    <button class="px-3 py-1 bg-gray-100 rounded-lg text-sm">7d</button>
                    <button class="px-3 py-1 bg-gray-100 rounded-lg text-sm">30d</button>
                    <button class="px-3 py-1 bg-gray-100 rounded-lg text-sm">1y</button>
                </div>
            </div>
            <div class="h-64">
                <canvas id="marketChart"></canvas>
            </div>
        </div>

        <div class="bg-white rounded-xl shadow-md overflow-hidden">
            <div class="flex justify-between items-center p-6 border-b">
                <h2 class="text-xl font-bold">Top Cryptocurrencies</h2>
                <div class="flex items-center space-x-2">
                    <span class="text-sm text-gray-500">Updated: Just now</span>
                    <button class="p-2 rounded-full hover:bg-gray-100">
                        <i data-feather="refresh-cw" class="w-4 h-4"></i>
                    </button>
                </div>
            </div>
            <div class="overflow-x-auto">
                <table class="w-full">
                    <thead>
                        <tr class="border-b text-gray-500 text-left">
                            <th class="p-4">#</th>
                            <th class="p-4">Name</th>
                            <th class="p-4">Price</th>
                            <th class="p-4">24h %</th>
                            <th class="p-4">7d %</th>
                            <th class="p-4">Market Cap</th>
                            <th class="p-4">Volume (24h)</th>
                            <th class="p-4">Last 7 Days</th>
                        </tr>
                    </thead>
                    <tbody id="cryptoTableBody">
                        <!-- Crypto data will be loaded here -->
                    </tbody>
                </table>
            </div>
            <div class="p-4 border-t flex justify-between items-center">
                <span class="text-sm text-gray-500">Showing 1-10 of 100 cryptocurrencies</span>
                <div class="flex space-x-2">
                    <button class="px-3 py-1 bg-gray-100 rounded-lg text-sm">Previous</button>
                    <button class="px-3 py-1 bg-primary-500 text-white rounded-lg text-sm">Next</button>
                </div>
            </div>
        </div>
    </main>

    <script>
        // Sample data - in a real app, you would fetch this from an API
        const cryptoData = [
            { rank: 1, name: "Bitcoin", symbol: "BTC", price: 42563.78, change24h: 2.34, change7d: -1.23, marketCap: 816452000000, volume: 28475200000, sparkline: [40000, 40500, 41000, 41500, 42000, 42250, 42563] },
            { rank: 2, name: "Ethereum", symbol: "ETH", price: 2365.42, change24h: -1.23, change7d: 3.45, marketCap: 284652000000, volume: 15432000000, sparkline: [2300, 2325, 2340, 2350, 2360, 2362, 2365] },
            { rank: 3, name: "Binance Coin", symbol: "BNB", price: 324.56, change24h: 0.45, change7d: 1.23, marketCap: 49876000000, volume: 1456000000, sparkline: [320, 322, 323, 324, 324.5, 324.3, 324.56] },
            { rank: 4, name: "Solana", symbol: "SOL", price: 102.34, change24h: 5.67, change7d: 8.90, marketCap: 43256000000, volume: 2345000000, sparkline: [95, 97, 98, 100, 101, 102, 102.34] },
            { rank: 5, name: "Cardano", symbol: "ADA", price: 0.56, change24h: -2.34, change7d: -1.23, marketCap: 19876000000, volume: 876500000, sparkline: [0.58, 0.57, 0.57, 0.56, 0.56, 0.56, 0.56] },
            { rank: 6, name: "XRP", symbol: "XRP", price: 0.52, change24h: 1.23, change7d: -0.56, marketCap: 25432000000, volume: 1234000000, sparkline: [0.51, 0.515, 0.52, 0.52, 0.525, 0.52, 0.52] },
            { rank: 7, name: "Polkadot", symbol: "DOT", price: 6.78, change24h: -0.45, change7d: 1.23, marketCap: 7654000000, volume: 345600000, sparkline: [6.7, 6.72, 6.75, 6.76, 6.77, 6.78, 6.78] },
            { rank: 8, name: "Dogecoin", symbol: "DOGE", price: 0.12, change24h: 3.45, change7d: 5.67, marketCap: 15678000000, volume: 987600000, sparkline: [0.115, 0.116, 0.118, 0.119, 0.12, 0.121, 0.12] },
            { rank: 9, name: "Avalanche", symbol: "AVAX", price: 34.56, change24h: -1.23, change7d: 2.34, marketCap: 8765000000, volume: 456700000, sparkline: [35, 34.8, 34.7, 34.6, 34.5, 34.55, 34.56] },
            { rank: 10, name: "Polygon", symbol: "MATIC", price: 0.78, change24h: 0.56, change7d: -1.23, marketCap: 6543000000, volume: 234500000, sparkline: [0.77, 0.775, 0.78, 0.785, 0.78, 0.78, 0.78] }
        ];

        // Format numbers for display
        function formatNumber(num, decimals = 2) {
            return num.toLocaleString(undefined, {
                minimumFractionDigits: decimals,
                maximumFractionDigits: decimals
            });
        }

        // Format large numbers with suffixes
        function formatLargeNumber(num) {
            if (num >= 1000000000) {
                return '$' + (num / 1000000000).toFixed(2) + 'B';
            }
            if (num >= 1000000) {
                return '$' + (num / 1000000).toFixed(2) + 'M';
            }
            return '$' + formatNumber(num);
        }

        // Generate sparkline SVG
        function generateSparkline(data) {
            const width = 100;
            const height = 40;
            const padding = 5;
            
            // Find min and max values
            const min = Math.min(...data);
            const max = Math.max(...data);
            const range = max - min;
            
            // Scale values to fit height
            const points = data.map((value, i) => {
                const x = (i / (data.length - 1)) * (width - padding * 2) + padding;
                const y = height - padding - ((value - min) / range) * (height - padding * 2);
                return `${x},${y}`;
            }).join(' ');
            
            return `<svg width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">
                <polyline points="${points}" fill="none" stroke="${range > 0 ? (data[data.length-1] >= data[0] ? '#10b981' : '#ef4444') : '#6b7280'}" stroke-width="2" />
            </svg>`;
        }

        // Populate crypto table
        function populateCryptoTable() {
            const tableBody = document.getElementById('cryptoTableBody');
            tableBody.innerHTML = '';
            
            cryptoData.forEach(crypto => {
                // Fallback icon URL in case the primary one fails
                const iconUrl = `https://cryptoicons.org/api/icon/${crypto.symbol.toLowerCase()}/30`;
                const fallbackIconUrl = 'https://cryptoicons.org/api/icon/generic/30';
const row = document.createElement('tr');
                row.className = 'border-b hover:bg-gray-50';
                
                row.innerHTML = `
                    <td class="p-4 text-gray-500">${crypto.rank}</td>
                    <td class="p-4 font-medium">
                        <div class="flex items-center">
                            <img src="https://cryptoicons.org/api/icon/${crypto.symbol.toLowerCase()}/30" alt="${crypto.name}" class="w-6 h-6 mr-3" onerror="this.src='https://cryptoicons.org/api/icon/generic/30'">
${crypto.name} <span class="text-gray-500 ml-2">${crypto.symbol}</span>
                        </div>
                    </td>
                    <td class="p-4 font-medium">$${formatNumber(crypto.price)}</td>
                    <td class="p-4 ${crypto.change24h >= 0 ? 'price-up' : 'price-down'}">${crypto.change24h >= 0 ? '+' : ''}${formatNumber(crypto.change24h)}%</td>
                    <td class="p-4 ${crypto.change7d >= 0 ? 'price-up' : 'price-down'}">${crypto.change7d >= 0 ? '+' : ''}${formatNumber(crypto.change7d)}%</td>
                    <td class="p-4">${formatLargeNumber(crypto.marketCap)}</td>
                    <td class="p-4">${formatLargeNumber(crypto.volume)}</td>
                    <td class="p-4">${generateSparkline(crypto.sparkline)}</td>
                `;
                
                tableBody.appendChild(row);
            });
        }

        // Initialize market chart
        function initMarketChart() {
            const ctx = document.getElementById('marketChart').getContext('2d');
            new Chart(ctx, {
                type: 'line',
                data: {
                    labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'],
                    datasets: [
                        {
                            label: 'Bitcoin (BTC)',
                            data: [30000, 32000, 35000, 38000, 40000, 41000, 42563],
                            borderColor: '#f59e0b',
                            backgroundColor: 'rgba(245, 158, 11, 0.1)',
                            tension: 0.3,
                            fill: true
                        },
                        {
                            label: 'Ethereum (ETH)',
                            data: [1800, 1900, 2100, 2200, 2300, 2350, 2365],
                            borderColor: '#6366f1',
                            backgroundColor: 'rgba(99, 102, 241, 0.1)',
                            tension: 0.3,
                            fill: true
                        },
                        {
                            label: 'Market Index',
                            data: [25000, 27000, 29000, 31000, 33000, 35000, 36000],
                            borderColor: '#10b981',
                            backgroundColor: 'rgba(16, 185, 129, 0.1)',
                            tension: 0.3,
                            fill: true
                        }
                    ]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    plugins: {
                        legend: {
                            position: 'bottom',
                        },
                        tooltip: {
                            mode: 'index',
                            intersect: false,
                        }
                    },
                    scales: {
                        y: {
                            beginAtZero: false,
                            ticks: {
                                callback: function(value) {
                                    return '$' + value.toLocaleString();
                                }
                            }
                        }
                    },
                    interaction: {
                        mode: 'nearest',
                        axis: 'x',
                        intersect: false
                    }
                }
            });
        }

        // Initialize the page
        document.addEventListener('DOMContentLoaded', function() {
            feather.replace();
            populateCryptoTable();
            initMarketChart();
            
            // Simulate real-time updates (in a real app, you would use WebSockets)
            setInterval(() => {
                cryptoData.forEach(crypto => {
                    // Simulate small price changes
                    const randomChange = (Math.random() - 0.5) * 2;
                    crypto.price *= (1 + randomChange / 100);
                    crypto.change24h += randomChange / 10;
                });
                populateCryptoTable();
            }, 5000);
        });
    </script>
</body>
</html>