import './market-movers.scss';
import { moveDir, formatFlucRate } from '@/types/worldIndex';
import { type MarketMoversResponse, type MarketMoverGroup, MARKET_LABEL, formatStockPrice, formatMoverCount } from '@/types/marketMover';
import Sparkline from './Sparkline';
// 등락 상위 종목 — 상승/하락/상한/하한 4그룹 각 상위 5. 종목명·시장·코드 + 미니 스파크라인 + 현재가·등락률.
// 상승/하락은 상한·하한 제외(비중복). 등락색 --price-up/down(상승 적/하락 청).
type Props = {
data: MarketMoversResponse;
};
const GROUPS: { key: 'advances'|'declines'|'limitUp'|'limitDown'; label: string; tone: 'up'|'down' }[] = [
{ key: 'advances', label: '상승', tone: 'up' },
{ key: 'declines', label: '하락', tone: 'down' },
{ key: 'limitUp', label: '상한', tone: 'up' },
{ key: 'limitDown', label: '하한', tone: 'down' }
];
const ARROW = { up: '▲', down: '▼', flat: '–' } as const;
export default function MarketMovers({ data }: Props)
{
const hasAny = data.advances.items.length > 0
|| data.declines.items.length > 0
|| data.limitUp.items.length > 0
|| data.limitDown.items.length > 0;
if (!hasAny) {
return null;
}
return (
등락 종목
{data.tradeDate && {data.tradeDate} 기준}
해당 종목 없음
) : (