mvbhr commited on
Commit
48911bf
·
verified ·
1 Parent(s): 141fd51

Upload components/StockCard.js with huggingface_hub

Browse files
Files changed (1) hide show
  1. components/StockCard.js +43 -0
components/StockCard.js ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export default function StockCard({ stock, onClick, isSelected }) {
2
+ const isPositive = parseFloat(stock.change) >= 0
3
+
4
+ return (
5
+ <div
6
+ onClick={onClick}
7
+ className={`stock-card cursor-pointer transition-all duration-200 ${
8
+ isSelected ? 'ring-2 ring-primary-500 bg-primary-50' : ''
9
+ }`}
10
+ >
11
+ <div className="flex justify-between items-start mb-3">
12
+ <div>
13
+ <h3 className="font-semibold text-gray-900">{stock.symbol}</h3>
14
+ <p className="text-sm text-gray-500">{stock.name}</p>
15
+ </div>
16
+ <div className={`text-xs px-2 py-1 rounded-full ${
17
+ isPositive ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800'
18
+ }`}>
19
+ {stock.changePercent > 0 ? '+' : ''}{stock.changePercent}%
20
+ </div>
21
+ </div>
22
+
23
+ <div className="flex justify-between items-end">
24
+ <div>
25
+ <p className="text-2xl font-bold text-gray-900">
26
+ ${stock.price}
27
+ </p>
28
+ <p className={`text-sm font-medium ${
29
+ isPositive ? 'stock-positive' : 'stock-negative'
30
+ }`}>
31
+ {isPositive ? '↑' : '↓'} {Math.abs(stock.change)}
32
+ </p>
33
+ </div>
34
+ <div className="text-right">
35
+ <p className="text-xs text-gray-500">Vol</p>
36
+ <p className="text-sm font-medium text-gray-700">
37
+ {(stock.volume / 1000000).toFixed(1)}M
38
+ </p>
39
+ </div>
40
+ </div>
41
+ </div>
42
+ )
43
+ }