cryptopulse-tracker / index.html
ThugHingface's picture
add real icons to currencies
20242c6 verified
Raw History Blame Contribute Delete
16.7 kB
<!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>