superxuu commited on
Commit
d4bf3e2
·
1 Parent(s): a8c58ea

style: Make StockHeader responsive and adaptive to different screen widths

Browse files
frontend/src/components/StockHeader.tsx CHANGED
@@ -36,62 +36,62 @@ export default function StockHeader({ cursorData }: StockHeaderProps) {
36
  const displayDate = date || (cursorData?.time ? cursorData.time.toString() : '--');
37
 
38
  return (
39
- <div className="bg-[#191B28] px-6 py-3 border-b border-[#2A2D3C] flex items-center justify-between shadow-md z-10">
40
- <div className="flex items-center gap-8">
41
  {/* 股票名称代码 */}
42
- <div className="w-[100px] shrink-0">
43
- <div className="text-2xl font-bold text-white tracking-wide">
44
  {isRevealed ? realName : '盲盒股票'}
45
  </div>
46
- <div className="text-sm text-gray-400 font-mono mt-1">
47
  {isRevealed ? realCode : '******'}
48
  </div>
49
  </div>
50
 
51
  {/* 当前价格 & 日期 */}
52
- <div className="w-[120px] shrink-0 flex flex-col items-start">
53
- <div className={`text-4xl font-bold font-mono ${colorClass} w-full`}>
54
  {close?.toFixed(2)}
55
  </div>
56
- <div className="text-sm text-gray-400 font-mono mt-1 font-bold">
57
  {displayDate}
58
  </div>
59
  </div>
60
 
61
  {/* 涨跌幅 */}
62
- <div className="w-[90px] shrink-0 flex flex-col justify-center text-sm font-medium items-start">
63
- <div className={`w-full ${colorClass}`}>
64
- <span className="text-lg font-mono">
65
  {displayPercent ? (displayPercent > 0 ? '+' : '') + displayPercent.toFixed(2) + '%' : '--'}
66
  </span>
67
  </div>
68
- <div className={`w-full ${colorClass}`}>
69
  <span className="font-mono">{displayChange ? displayChange.toFixed(2) : '--'}</span>
70
  </div>
71
  </div>
72
 
73
- {/* 详细数据 */}
74
- <div className="flex gap-6 text-sm">
75
- <div className="w-[65px] shrink-0 flex flex-col items-end">
76
- <span className="text-gray-500 text-xs">今开</span>
77
  <span className={`font-mono ${open >= close ? 'text-[#00F0F0]' : 'text-[#FD1050]'}`}>
78
  {open?.toFixed(2)}
79
  </span>
80
  </div>
81
- <div className="w-[65px] shrink-0 flex flex-col items-end">
82
- <span className="text-gray-500 text-xs">最高</span>
83
  <span className={`font-mono ${high >= close ? 'text-[#FD1050]' : 'text-[#00F0F0]'}`}>
84
  {high?.toFixed(2)}
85
  </span>
86
  </div>
87
- <div className="w-[65px] shrink-0 flex flex-col items-end">
88
- <span className="text-gray-500 text-xs">最低</span>
89
  <span className={`font-mono ${low >= close ? 'text-[#FD1050]' : 'text-[#00F0F0]'}`}>
90
  {low?.toFixed(2)}
91
  </span>
92
  </div>
93
- <div className="w-[75px] shrink-0 flex flex-col items-end">
94
- <span className="text-gray-500 text-xs">成交量</span>
95
  <span className="text-yellow-400 font-mono">
96
  {volume ? (
97
  volume >= 100000000
@@ -100,14 +100,14 @@ export default function StockHeader({ cursorData }: StockHeaderProps) {
100
  ) : '--'}
101
  </span>
102
  </div>
103
- <div className="w-[65px] shrink-0 flex flex-col items-end">
104
- <span className="text-gray-500 text-xs">量比</span>
105
  <span className="text-purple-400 font-mono">
106
  {volume_ratio?.toFixed(2) || '--'}
107
  </span>
108
  </div>
109
- <div className="w-[75px] shrink-0 flex flex-col items-end">
110
- <span className="text-gray-500 text-xs">换手率</span>
111
  <span className="text-cyan-400 font-mono">
112
  {turnover_rate?.toFixed(2) || '--'}%
113
  </span>
@@ -116,12 +116,13 @@ export default function StockHeader({ cursorData }: StockHeaderProps) {
116
  </div>
117
 
118
  {/* 进度信息 */}
119
- <div className="w-[100px] shrink-0 text-right">
120
- <div className="text-gray-400 text-xs mb-1">当前进度</div>
121
- <div className="text-white font-mono text-lg">
122
  {currentIndex + 1} <span className="text-gray-600">/</span> {allKlines.length}
123
  </div>
124
  </div>
125
  </div>
126
  );
 
127
  }
 
36
  const displayDate = date || (cursorData?.time ? cursorData.time.toString() : '--');
37
 
38
  return (
39
+ <div className="bg-[#191B28] px-4 lg:px-6 py-2 lg:py-3 border-b border-[#2A2D3C] flex flex-wrap items-center justify-between shadow-md z-10 gap-y-2">
40
+ <div className="flex flex-wrap items-center gap-x-4 lg:gap-x-8 gap-y-2 flex-1 min-w-0">
41
  {/* 股票名称代码 */}
42
+ <div className="shrink-0 min-w-[80px]">
43
+ <div className="text-xl lg:text-2xl font-bold text-white tracking-wide truncate">
44
  {isRevealed ? realName : '盲盒股票'}
45
  </div>
46
+ <div className="text-xs lg:text-sm text-gray-400 font-mono mt-0.5">
47
  {isRevealed ? realCode : '******'}
48
  </div>
49
  </div>
50
 
51
  {/* 当前价格 & 日期 */}
52
+ <div className="shrink-0 flex flex-col items-start min-w-[100px]">
53
+ <div className={`text-2xl lg:text-4xl font-bold font-mono ${colorClass}`}>
54
  {close?.toFixed(2)}
55
  </div>
56
+ <div className="text-[10px] lg:text-sm text-gray-400 font-mono mt-0.5 font-bold">
57
  {displayDate}
58
  </div>
59
  </div>
60
 
61
  {/* 涨跌幅 */}
62
+ <div className="shrink-0 flex flex-col justify-center text-xs lg:text-sm font-medium items-start min-w-[70px]">
63
+ <div className={`${colorClass}`}>
64
+ <span className="text-base lg:text-lg font-mono">
65
  {displayPercent ? (displayPercent > 0 ? '+' : '') + displayPercent.toFixed(2) + '%' : '--'}
66
  </span>
67
  </div>
68
+ <div className={`${colorClass}`}>
69
  <span className="font-mono">{displayChange ? displayChange.toFixed(2) : '--'}</span>
70
  </div>
71
  </div>
72
 
73
+ {/* 详细数据 - 使用 flex-1 和 min-w-0 实现自适应 */}
74
+ <div className="flex flex-wrap items-center gap-x-4 lg:gap-x-6 gap-y-1 text-xs lg:text-sm flex-1 min-w-0">
75
+ <div className="flex flex-col items-end shrink-0">
76
+ <span className="text-gray-500 text-[10px] lg:text-xs">今开</span>
77
  <span className={`font-mono ${open >= close ? 'text-[#00F0F0]' : 'text-[#FD1050]'}`}>
78
  {open?.toFixed(2)}
79
  </span>
80
  </div>
81
+ <div className="flex flex-col items-end shrink-0">
82
+ <span className="text-gray-500 text-[10px] lg:text-xs">最高</span>
83
  <span className={`font-mono ${high >= close ? 'text-[#FD1050]' : 'text-[#00F0F0]'}`}>
84
  {high?.toFixed(2)}
85
  </span>
86
  </div>
87
+ <div className="flex flex-col items-end shrink-0">
88
+ <span className="text-gray-500 text-[10px] lg:text-xs">最低</span>
89
  <span className={`font-mono ${low >= close ? 'text-[#FD1050]' : 'text-[#00F0F0]'}`}>
90
  {low?.toFixed(2)}
91
  </span>
92
  </div>
93
+ <div className="flex flex-col items-end shrink-0">
94
+ <span className="text-gray-500 text-[10px] lg:text-xs">成交量</span>
95
  <span className="text-yellow-400 font-mono">
96
  {volume ? (
97
  volume >= 100000000
 
100
  ) : '--'}
101
  </span>
102
  </div>
103
+ <div className="flex flex-col items-end shrink-0">
104
+ <span className="text-gray-500 text-[10px] lg:text-xs">量比</span>
105
  <span className="text-purple-400 font-mono">
106
  {volume_ratio?.toFixed(2) || '--'}
107
  </span>
108
  </div>
109
+ <div className="flex flex-col items-end shrink-0">
110
+ <span className="text-gray-500 text-[10px] lg:text-xs">换手率</span>
111
  <span className="text-cyan-400 font-mono">
112
  {turnover_rate?.toFixed(2) || '--'}%
113
  </span>
 
116
  </div>
117
 
118
  {/* 进度信息 */}
119
+ <div className="shrink-0 text-right ml-auto pl-4 border-l border-gray-800 lg:border-none">
120
+ <div className="text-gray-400 text-[10px] lg:text-xs mb-0.5">当前进度</div>
121
+ <div className="text-white font-mono text-sm lg:text-lg">
122
  {currentIndex + 1} <span className="text-gray-600">/</span> {allKlines.length}
123
  </div>
124
  </div>
125
  </div>
126
  );
127
+ );
128
  }