fix(energy): 顶部双 sticky 间隙泄露 + 加氢站名单价完整显示
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
问题 1:原本「氢能/电能/ETC」与「每日/总览」是两个独立的 sticky 元素,分别 top:0 / top:[58px],中间 gap-3 +位置不精确导致滚动时 图表内容从 14px 缝隙里穿过。 修复: - 把 HydrogenView 内部的 sub-tab 状态提到 EnergyModule - top tab + 子 tab 合并到「同一张白色 rounded-2xl 卡片」里,无内部间隙 - 外层 sticky 容器 frosted glass:bg-[#F8F9FB]/85 + backdrop-blur-md -mx -mt 扩到页面边,消除左右上的微缝 - HydrogenView 改为受控组件(接收 sub prop) 问题 2:站点行 mobile 上 name + ' · 价格' 共用一格还 truncate, 导致长名称(广州新锋交通联新…/上海浦江加氢站…)截断、单价不可见。 修复: - 行改为「站名换行 + 下方单价 chip」纵向排列 - 单价用 amber 小徽章「单价 X 元/Kg」,不再 inline 跟着名字 - name 用 break-words 允许折行,items-start 顶部对齐 - 单价为 0(免费/赠送)时不显示徽章,desktop 列里显示「—」 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,37 +1,12 @@
|
||||
import { useState } from 'react';
|
||||
import { LayoutDashboard, CalendarDays } from 'lucide-react';
|
||||
import HydrogenOverview from './HydrogenOverview';
|
||||
import HydrogenDaily from './HydrogenDaily';
|
||||
|
||||
type SubTab = 'daily' | 'overview';
|
||||
export type HydrogenSubTab = 'daily' | 'overview';
|
||||
|
||||
const SUB_TABS: Array<{ id: SubTab; label: string; icon: typeof LayoutDashboard }> = [
|
||||
{ id: 'daily', label: '每日', icon: CalendarDays },
|
||||
{ id: 'overview', label: '总览', icon: LayoutDashboard },
|
||||
];
|
||||
|
||||
export default function HydrogenView() {
|
||||
const [sub, setSub] = useState<SubTab>('daily');
|
||||
return (
|
||||
<>
|
||||
<div className="bg-white rounded-2xl border border-slate-100 shadow-sm p-1 sticky top-[58px] z-20 flex gap-1">
|
||||
{SUB_TABS.map(({ id, label, icon: Icon }) => {
|
||||
const active = sub === id;
|
||||
return (
|
||||
<button
|
||||
key={id}
|
||||
onClick={() => setSub(id)}
|
||||
className={`flex-1 flex items-center justify-center gap-1.5 rounded-xl py-1.5 text-[12px] font-bold transition-all ${
|
||||
active ? 'bg-blue-50 text-blue-600' : 'text-slate-400 hover:bg-slate-50'
|
||||
}`}
|
||||
>
|
||||
<Icon size={14} />
|
||||
<span>{label}</span>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{sub === 'overview' ? <HydrogenOverview /> : <HydrogenDaily />}
|
||||
</>
|
||||
);
|
||||
interface Props {
|
||||
sub: HydrogenSubTab;
|
||||
}
|
||||
|
||||
export default function HydrogenView({ sub }: Props) {
|
||||
return sub === 'overview' ? <HydrogenOverview /> : <HydrogenDaily />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user