Spaces:
Sleeping
Sleeping
Naufal Arhab
fix(audit): resolve multi-pass backend calculations, exchange guards, AI/UI state, and chart bugs
80df99b Download frontend/src/components/layout/Sidebar.tsx from agus1111/Perps-Terminal: direct link, hf CLI and curl.
- Browser
- Download file 3.44 kB
-
https://huggingface.co/spaces/agus1111/Perps-Terminal/resolve/main/frontend/src/components/layout/Sidebar.tsx
- Command line
-
hf download hf://spaces/agus1111/Perps-Terminal/frontend/src/components/layout/Sidebar.tsx
-
curl -L -o Sidebar.tsx https://huggingface.co/spaces/agus1111/Perps-Terminal/resolve/main/frontend/src/components/layout/Sidebar.tsx
3.44 kB
| import { useState, lazy, Suspense } from 'react'; | |
| import { Plus, BarChart3 } from 'lucide-react'; | |
| import { PairList } from '../pairs/PairList'; | |
| import { Button } from '../ui/Button'; | |
| import type { Pair, Signal } from '../../types'; | |
| const AddPairModal = lazy(() => | |
| import('../pairs/AddPairModal').then((m) => ({ default: m.AddPairModal })) | |
| ); | |
| interface SidebarProps { | |
| pairs: Pair[]; | |
| signals: Signal[]; | |
| isLoading: boolean; | |
| selectedSymbol: string | null; | |
| onSelect: (symbol: string) => void; | |
| } | |
| export function Sidebar({ pairs, signals, isLoading, selectedSymbol, onSelect }: SidebarProps) { | |
| const [isAddModalOpen, setIsAddModalOpen] = useState(false); | |
| const activePairCount = pairs.filter((p) => p.is_active).length; | |
| return ( | |
| <> | |
| <aside className="w-64 lg:w-72 xl:w-80 shrink-0 flex flex-col border-r border-border bg-bg-card overflow-hidden"> | |
| {/* Sidebar header */} | |
| <div className="px-4 py-3 border-b border-border"> | |
| <div className="flex items-center justify-between mb-3"> | |
| <div className="flex items-center gap-2"> | |
| <BarChart3 size={14} className="text-accent-blue" /> | |
| <span className="text-xs font-semibold text-text-secondary uppercase tracking-wider"> | |
| Pairs | |
| </span> | |
| </div> | |
| {activePairCount > 0 && ( | |
| <span className="text-[10px] font-mono bg-accent-blue/10 text-accent-blue border border-accent-blue/20 px-1.5 py-0.5 rounded"> | |
| {activePairCount} active | |
| </span> | |
| )} | |
| </div> | |
| <Button | |
| variant="primary" | |
| size="sm" | |
| onClick={() => setIsAddModalOpen(true)} | |
| icon={<Plus size={13} />} | |
| className="w-full justify-center" | |
| > | |
| Add Pair | |
| </Button> | |
| </div> | |
| {/* Pair list */} | |
| <div className="flex-1 overflow-y-auto py-2"> | |
| <PairList | |
| pairs={pairs} | |
| signals={signals} | |
| isLoading={isLoading} | |
| selectedSymbol={selectedSymbol} | |
| onSelect={onSelect} | |
| /> | |
| </div> | |
| {/* Footer stats */} | |
| <div className="px-4 py-3 border-t border-border"> | |
| <div className="grid grid-cols-3 gap-2 text-center"> | |
| {(['LONG', 'SHORT', 'NEUTRAL'] as const).map((dir) => { | |
| const activeSymbolSet = new Set(pairs.filter((p) => p.is_active).map((p) => p.symbol)); | |
| const count = signals.filter( | |
| (s) => activeSymbolSet.has(s.symbol) && s.direction === dir | |
| ).length; | |
| return ( | |
| <div key={dir}> | |
| <p | |
| className={`text-sm font-bold font-mono ${ | |
| dir === 'LONG' | |
| ? 'text-signal-long' | |
| : dir === 'SHORT' | |
| ? 'text-signal-short' | |
| : 'text-text-muted' | |
| }`} | |
| > | |
| {count} | |
| </p> | |
| <p className="text-[10px] text-text-muted">{dir}</p> | |
| </div> | |
| ); | |
| })} | |
| </div> | |
| </div> | |
| </aside> | |
| {isAddModalOpen && ( | |
| <Suspense fallback={null}> | |
| <AddPairModal isOpen={isAddModalOpen} onClose={() => setIsAddModalOpen(false)} /> | |
| </Suspense> | |
| )} | |
| </> | |
| ); | |
| } | |