데모 콘솔 디자인 개편 — 미니멀 라이트 테마·컴포넌트 라이브러리 도입·제안가 추이 차트

- 연회색 바탕 위 무보더 흰 카드, 단일 파랑 악센트, 숫자 tabular-nums 통일
- 가격 트랙 → 제안가 추이 영역 차트(기준선 3종 점선·라벨 자동 스태거·합의가 종점 연결)
- 채팅 말풍선·버튼·배지·진행표시를 컴포넌트 라이브러리 기반으로 재작성
- 완료 배너에 최종 합의가·절감률 강조, 로딩·빈·오류 상태 문구 정비

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UFZ7JWdwCaQAwNYJErL8pP
This commit is contained in:
민헌andClaude Fable 5 committed 2026-08-31 14:04:05 +09:00
1 parent 156ce3817d
commit 66c0429ea2
10 files changed
+382 -246

No files matched your search

+21 -20
View File
@@ -10,10 +10,10 @@ export function CasePanel({
onStart: (c: DemoCase) => void
}) {
return (
<aside className="flex flex-col gap-3 min-[960px]:min-h-0 min-[960px]:overflow-y-auto">
<section className="rounded-xl border border-line bg-panel p-4">
<h2 className="text-xs font-semibold uppercase tracking-wider text-muted">협상 케이스</h2>
<ul className="mt-3 flex flex-col gap-2">
<aside className="flex flex-col gap-4 min-[960px]:min-h-0 min-[960px]:overflow-y-auto">
<section className="rounded-box bg-base-100 p-5">
<h2 className="text-xs font-semibold text-base-content/55">협상 케이스</h2>
<ul className="mt-3 flex flex-col gap-1.5">
{cases.map((c) => {
const active = started && c.id === selected.id
return (
@@ -22,27 +22,28 @@ export function CasePanel({
type="button"
disabled={busy}
onClick={() => onStart(c)}
className={`w-full rounded-lg border px-3 py-2.5 text-left transition-colors focus-visible:ring-2 focus-visible:ring-blue focus-visible:outline-none ${
active
? 'border-blue bg-blue-soft'
: 'border-line bg-panel hover:border-muted'
aria-pressed={active}
className={`w-full cursor-pointer rounded-field p-3 text-left transition-colors focus-visible:ring-2 focus-visible:ring-primary focus-visible:outline-none ${
active ? 'bg-primary/8 ring-1 ring-primary/30' : 'hover:bg-base-200'
} ${busy ? 'opacity-60' : ''}`}
>
<div className="flex items-center justify-between gap-2">
<span className="text-sm font-semibold">{c.item_name}</span>
<span className="shrink-0 rounded bg-paper px-1.5 py-0.5 text-[11px] text-muted">{c.label}</span>
<span className={`text-sm font-bold ${active ? 'text-primary' : ''}`}>{c.item_name}</span>
<span className="shrink-0 rounded-full bg-base-200 px-2 py-0.5 text-[10px] font-medium text-base-content/55">
{c.label}
</span>
</div>
<div className="mt-1 font-mono text-xs text-muted">
기존 공급가 {c.item_price.toLocaleString()}원
<div className="num mt-1 text-xs text-base-content/55">
기존 공급가 <span className="font-semibold text-base-content/80">{c.item_price.toLocaleString()}원</span>
</div>
{active && (
<dl className="mt-2 grid grid-cols-2 gap-x-2 gap-y-1 border-t border-line pt-2 text-[11px]">
<dt className="text-muted">공급 유형</dt>
<dd className="text-right">{DIST_LABEL[c.dist]} · {c.partners_yn}</dd>
<dt className="text-muted">거래 기간</dt>
<dd className="text-right font-mono">{c.card_data.trading_period}년</dd>
<dt className="text-muted">응답률 / VOC</dt>
<dd className="text-right font-mono">{c.card_data.response_rate}% / {c.card_data.voc_count}건</dd>
<dl className="mt-2.5 grid grid-cols-2 gap-x-2 gap-y-1 border-t border-primary/15 pt-2.5 text-[11px]">
<dt className="text-base-content/50">공급 유형</dt>
<dd className="text-right font-medium">{DIST_LABEL[c.dist]} · {c.partners_yn}</dd>
<dt className="text-base-content/50">거래 기간</dt>
<dd className="num text-right font-medium">{c.card_data.trading_period}년</dd>
<dt className="text-base-content/50">응답률 / VOC</dt>
<dd className="num text-right font-medium">{c.card_data.response_rate}% / {c.card_data.voc_count}건</dd>
</dl>
)}
</button>
@@ -51,7 +52,7 @@ export function CasePanel({
})}
</ul>
{!started && (
<p className="mt-3 text-xs leading-relaxed text-muted">
<p className="mt-3 text-xs leading-relaxed text-base-content/50">
케이스를 선택하면 협상이 시작됩니다. 챗봇은 구매 담당자(MD) 역할이고,
당신은 공급사로서 가격 제안에 응답합니다.
</p>
+52 -51
View File
@@ -52,16 +52,16 @@ export function ChatPanel({
: null
return (
<section className="flex min-h-[70vh] flex-col rounded-xl border border-line bg-panel min-[960px]:h-full min-[960px]:min-h-0">
<section className="flex min-h-[70vh] flex-col rounded-box bg-base-100 min-[960px]:h-full min-[960px]:min-h-0">
{started && (
<div className="flex items-center justify-between gap-3 border-b border-line px-4 py-2.5">
<span className="truncate text-sm font-semibold">{demoCase.item_name}</span>
<div className="flex items-center justify-between gap-3 border-b border-base-300/60 px-5 py-3">
<span className="truncate text-sm font-bold">{demoCase.item_name}</span>
{!nego.done && (
<button
type="button"
onClick={onRestart}
disabled={busy}
className="shrink-0 rounded-md border border-line px-2.5 py-1 text-xs text-muted hover:border-muted hover:text-ink disabled:opacity-40 focus-visible:ring-2 focus-visible:ring-blue focus-visible:outline-none"
className="btn btn-ghost btn-xs text-base-content/55"
>
다시 시작
</button>
@@ -69,94 +69,95 @@ export function ChatPanel({
</div>
)}
<div ref={scroller} className="flex-1 overflow-y-auto p-4">
<div ref={scroller} className="flex-1 overflow-y-auto px-5 py-4">
{!started && (
<div className="flex h-full flex-col items-center justify-center gap-2 text-center text-muted">
<p className="text-base font-medium text-ink">협상 준비 완료</p>
<p className="max-w-sm text-sm leading-relaxed">
왼쪽에서 협상 케이스를 선택하세요. 협상 카드·가격 지표·긴장도가
오른쪽 계기판에 실시간으로 표시됩니다.
<div className="flex h-full flex-col items-center justify-center gap-2 text-center">
<p className="text-lg font-bold">어떤 품목으로 협상해 볼까요?</p>
<p className="max-w-sm text-sm leading-relaxed text-base-content/55">
왼쪽에서 협상 케이스를 선택하면 시작됩니다. 엔진의 판단 근거는
오른쪽 계기판에 실시간으로 표시돼요.
</p>
</div>
)}
<ol className="flex flex-col gap-3">
<ol className="flex flex-col gap-1">
{messages.map((m, i) => (
<li key={i} className={`msg-in flex ${m.role === 'user' ? 'justify-end' : 'justify-start'}`}>
<li key={i} className={`msg-in chat ${m.role === 'user' ? 'chat-end' : 'chat-start'}`}>
{m.role === 'bot' && m.step && (
<div className="chat-header mb-1 flex items-center gap-1.5 text-[11px] font-semibold text-base-content/45">
<span>{stepLabel(m.step)}</span>
{m.meta?.card_id && (
<span className="num rounded-full bg-primary/10 px-1.5 py-px font-mono text-primary">
{m.meta.card_id}
</span>
)}
</div>
)}
<div
className={`max-w-[min(82%,34rem)] rounded-2xl px-4 py-3 text-[15px] leading-relaxed whitespace-pre-line ${
className={`chat-bubble max-w-[min(85%,34rem)] text-[15px] leading-relaxed whitespace-pre-line before:hidden ${
m.role === 'user'
? 'rounded-br-md bg-blue text-white'
: 'rounded-bl-md bg-bot'
? 'bg-primary text-primary-content'
: 'bg-base-200 text-base-content'
}`}
>
{m.role === 'bot' && m.step && (
<div className="mb-1 flex items-center gap-2 text-[11px] font-semibold text-muted">
<span>{stepLabel(m.step)}</span>
{m.meta?.card_id && (
<span className="rounded bg-blue-soft px-1.5 py-px font-mono text-blue">{m.meta.card_id}</span>
)}
</div>
)}
{m.text}
</div>
</li>
))}
{busy && (
<li className="flex justify-start">
<div className="rounded-2xl rounded-bl-md bg-bot px-4 py-3 text-sm text-muted">협상 중…</div>
<li className="chat chat-start">
<div className="chat-bubble flex items-center gap-2 bg-base-200 text-sm text-base-content/55 before:hidden">
<span className="loading loading-dots loading-sm" aria-hidden />
담당자가 검토하고 있어요
</div>
</li>
)}
</ol>
{error && (
<p className="mt-3 rounded-lg bg-amber-soft px-3 py-2 text-sm text-amber">
{error} — 서버(:3300)가 켜져 있는지 확인한 뒤 다시 시도하세요.
</p>
<div className="mt-3 rounded-field bg-error/8 px-4 py-3 text-sm text-error">
{error} — 엔진 연결을 확인한 뒤 다시 시도해 주세요.
</div>
)}
</div>
<div className="border-t border-line p-3">
<div className="border-t border-base-300/60 p-4">
{nego.done ? (
<div className="flex flex-wrap items-center justify-between gap-3">
{finalPrice != null ? (
<span className="text-sm">
<span className="font-semibold text-green">협상 완료</span>
<span className="text-muted"> — 최종 합의가 </span>
<span className="font-mono font-semibold">{finalPrice.toLocaleString()}원</span>
<span className="font-mono text-blue"> (기존가 대비 −{savedPct}%)</span>
</span>
<div>
<p className="text-xs font-semibold text-success">협상 완료</p>
<p className="num mt-0.5 text-lg font-bold">
{finalPrice.toLocaleString()}원
<span className="num ml-2 align-[2px] rounded-full bg-primary/10 px-2 py-0.5 text-xs font-semibold text-primary">
기존가 대비 −{savedPct}%
</span>
</p>
</div>
) : (
<span className="text-sm font-semibold">협상이 종료되었습니다</span>
<span className="text-sm font-bold">협상이 종료되었습니다</span>
)}
<button
type="button"
onClick={onRestart}
className="rounded-lg bg-ink px-4 py-2 text-sm font-semibold text-white hover:bg-ink/85 focus-visible:ring-2 focus-visible:ring-blue focus-visible:outline-none"
>
<button type="button" onClick={onRestart} className="btn btn-neutral rounded-field">
같은 케이스로 다시 협상
</button>
</div>
) : nego.mode === 'price' ? (
<form
className="flex gap-2"
onSubmit={(e) => { e.preventDefault(); submitPrice() }}
>
<form className="flex gap-2" onSubmit={(e) => { e.preventDefault(); submitPrice() }}>
<label htmlFor="price" className="sr-only">공급 제안가 (원)</label>
<input
id="price"
inputMode="numeric"
autoComplete="off"
placeholder={`공급 제안가 입력 (기존가 ${demoCase.item_price.toLocaleString()}원)`}
placeholder={`제안가 입력 (기존가 ${demoCase.item_price.toLocaleString()}원)`}
value={priceInput}
onChange={(e) => setPriceInput(e.target.value)}
disabled={busy}
className="min-w-0 flex-1 rounded-lg border border-line bg-paper px-3 py-2.5 font-mono text-sm focus-visible:ring-2 focus-visible:ring-blue focus-visible:outline-none"
className="input num min-w-0 flex-1 bg-base-200 text-[15px] focus:outline-primary"
/>
<button
type="submit"
disabled={busy || !priceInput.trim()}
className="shrink-0 rounded-lg bg-blue px-5 py-2.5 text-sm font-semibold text-white disabled:opacity-40 hover:bg-blue/90 focus-visible:ring-2 focus-visible:ring-ink focus-visible:outline-none"
className="btn btn-primary shrink-0 rounded-field px-6"
>
제안
제안하기
</button>
</form>
) : nego.options.length > 0 ? (
@@ -167,14 +168,14 @@ export function ChatPanel({
type="button"
disabled={busy}
onClick={() => onAnswer(opt)}
className="rounded-lg border border-line bg-paper px-4 py-2.5 text-sm font-medium hover:border-blue hover:text-blue disabled:opacity-40 focus-visible:ring-2 focus-visible:ring-blue focus-visible:outline-none"
className="btn rounded-field border-0 bg-base-200 px-5 font-semibold hover:bg-primary/10 hover:text-primary"
>
{opt}
</button>
))}
</div>
) : (
<p className="py-1 text-center text-sm text-muted">
<p className="py-1 text-center text-sm text-base-content/45">
{started ? '응답을 기다리는 중…' : '케이스를 선택하면 입력이 열립니다'}
</p>
)}
+70 -36
View File
@@ -1,7 +1,7 @@
import type { ChatMetadata } from '../lib/api'
import type { DemoCase } from '../content/cases'
import type { NegoState } from '../App'
import { PriceTrack } from './PriceTrack'
import { PriceChart } from './PriceChart'
const FLOW = ['서비스안내', '담당자확인', '협상품목안내', '가격협상', '협상종료']
@@ -14,41 +14,69 @@ function flowIndex(step: string): number {
function Panel({ title, children }: { title: string; children: React.ReactNode }) {
return (
<section className="rounded-xl border border-line bg-panel p-4">
<h2 className="text-xs font-semibold uppercase tracking-wider text-muted">{title}</h2>
<section className="rounded-box bg-base-100 p-5">
<h2 className="text-xs font-semibold text-base-content/55">{title}</h2>
<div className="mt-3">{children}</div>
</section>
)
}
export function Dashboard({
demoCase, nego, meta, priceTrail, started,
demoCase, nego, meta, priceTrail, started, finalPrice,
}: {
demoCase: DemoCase
nego: NegoState
meta: ChatMetadata | null
priceTrail: number[]
started: boolean
finalPrice: number | null
}) {
const fi = started ? flowIndex(nego.step) : -1
const tension = meta?.tension ?? null
const indicator = meta?.indicator_value ?? null
// 합의가가 마지막 제안가와 다르면(1% 추가 네고 등) 차트 종점으로 잇는다
const series = finalPrice != null && priceTrail[priceTrail.length - 1] !== finalPrice
? [...priceTrail, finalPrice]
: priceTrail
const current = finalPrice ?? (priceTrail.length ? priceTrail[priceTrail.length - 1] : null)
const priceLabel = finalPrice != null ? '최종 합의가' : current != null ? '현재 제안가' : '기존 공급가'
const priceValue = current ?? demoCase.item_price
const savedPct = current != null && current < demoCase.item_price
? Math.round(((demoCase.item_price - current) / demoCase.item_price) * 1000) / 10
: null
return (
<aside className="flex flex-col gap-3 min-[960px]:min-h-0 min-[960px]:overflow-y-auto">
<Panel title="가격 트랙">
<PriceTrack demoCase={demoCase} priceTrail={priceTrail} />
<dl className="mt-3 flex items-center justify-between border-t border-line pt-2.5 text-xs">
<aside className="flex flex-col gap-4 min-[960px]:min-h-0 min-[960px]:overflow-y-auto">
<Panel title={priceLabel}>
<div className="flex items-baseline gap-2">
<p className="num text-2xl font-bold tracking-tight">
{priceValue.toLocaleString()}
<span className="ml-0.5 text-base font-semibold text-base-content/55">원</span>
</p>
{savedPct != null && (
<span className="num rounded-full bg-primary/10 px-2 py-0.5 text-xs font-semibold text-primary">
기존가 대비 −{savedPct}%
</span>
)}
</div>
<div className="mt-2">
<PriceChart demoCase={demoCase} priceTrail={series} />
</div>
<dl className="mt-2 flex items-center justify-between border-t border-base-300/60 pt-3 text-xs">
<div className="flex items-center gap-1.5">
<dt className="text-muted">시나리오</dt>
<dd className="font-mono font-medium">{demoCase.scenario.replace('Scenario_', '')}</dd>
<dt className="text-base-content/55">시나리오</dt>
<dd className="num font-semibold">{demoCase.scenario.replace('Scenario_', '')}</dd>
</div>
<div className="flex items-center gap-1.5">
<dt className="text-muted">인터넷 최저가</dt>
<dd className="font-mono font-medium">{demoCase.card_data.internet_min_price.toLocaleString()}원</dd>
<dt className="text-base-content/55">인터넷 최저가</dt>
<dd className="num font-semibold">{demoCase.card_data.internet_min_price.toLocaleString()}원</dd>
</div>
</dl>
<p className="mt-2 text-[11px] leading-relaxed text-muted">
<p className="mt-2 text-[11px] leading-relaxed text-base-content/45">
앵커가·목표가는 실제 협상에서 공급사에게 보이지 않는 구매측 내부 기준입니다.
</p>
</Panel>
@@ -58,44 +86,50 @@ export function Dashboard({
{FLOW.map((s, i) => (
<li key={s} className="flex flex-1 flex-col items-center gap-1.5">
<div
className={`h-1.5 w-full rounded-full ${
i < fi ? 'bg-blue/40' : i === fi ? 'bg-blue' : 'bg-line'
className={`h-1 w-full rounded-full ${
i < fi ? 'bg-primary/35' : i === fi ? 'bg-primary' : 'bg-base-200'
}`}
/>
<span className={`text-[10px] ${i === fi ? 'font-semibold text-ink' : 'text-muted'}`}>{s}</span>
<span
className={`text-[10px] ${i === fi ? 'font-semibold text-base-content' : 'text-base-content/45'}`}
>
{s}
</span>
</li>
))}
</ol>
<div className="mt-3 flex items-center justify-between text-sm">
<span className="text-muted">가격 라운드</span>
<span className="font-mono font-medium">{Math.min(nego.iteration + (nego.initial ? 1 : 0), 5)} / 5</span>
<span className="text-base-content/55">가격 라운드</span>
<span className="num font-semibold">{Math.min(nego.iteration + (nego.initial ? 1 : 0), 5)} / 5</span>
</div>
</Panel>
<Panel title="엔진 판단">
{meta ? (
<dl className="flex flex-col gap-3 text-sm">
<dl className="flex flex-col gap-4 text-sm">
<div className="flex items-center justify-between gap-2">
<dt className="text-muted">협상 카드</dt>
<dd className="rounded bg-blue-soft px-2 py-0.5 font-mono text-[13px] font-medium text-blue">
{meta.card_id ?? '—'}
<dt className="text-base-content/55">협상 카드</dt>
<dd>
<span className="badge badge-soft badge-primary num font-mono text-[12px] font-semibold">
{meta.card_id ?? '—'}
</span>
</dd>
</div>
<div>
<div className="flex items-center justify-between">
<dt className="text-muted">가격 지표</dt>
<dd className="font-mono text-[13px]">
<dt className="text-base-content/55">가격 지표</dt>
<dd className="num text-[13px] font-medium">
{indicator != null ? (
<>
{indicator} <span className="text-muted">/ 99 · {meta.indicator_range}</span>
{indicator} <span className="text-base-content/45">/ 99 · {meta.indicator_range}</span>
</>
) : '—'}
</dd>
</div>
<div className="mt-1.5 h-1.5 rounded-full bg-paper">
<div className="mt-2 h-1.5 rounded-full bg-base-200">
<div
className="h-full rounded-full bg-blue transition-[width] duration-500"
className="h-full rounded-full bg-primary transition-[width] duration-500 motion-reduce:transition-none"
style={{ width: `${indicator ?? 0}%` }}
/>
</div>
@@ -103,34 +137,34 @@ export function Dashboard({
<div>
<div className="flex items-center justify-between">
<dt className="text-muted">협상 긴장도</dt>
<dd className="font-mono text-[13px]">{tension != null ? tension.toFixed(2) : '—'}</dd>
<dt className="text-base-content/55">협상 긴장도</dt>
<dd className="num text-[13px] font-medium">{tension != null ? tension.toFixed(2) : '—'}</dd>
</div>
<div className="mt-1.5 h-1.5 rounded-full bg-paper">
<div className="mt-2 h-1.5 rounded-full bg-base-200">
<div
className="h-full rounded-full bg-amber transition-[width] duration-500"
className="h-full rounded-full bg-warning transition-[width] duration-500 motion-reduce:transition-none"
style={{ width: `${(tension ?? 0) * 100}%` }}
/>
</div>
</div>
<div className="flex items-center justify-between gap-2">
<dt className="text-muted">적용 페르소나</dt>
<dt className="text-base-content/55">적용 페르소나</dt>
<dd>
{meta.persona ? (
<span className="rounded bg-amber-soft px-2 py-0.5 text-[13px] font-medium text-amber">
<span className="badge badge-soft badge-warning text-[12px] font-semibold">
{meta.persona}
</span>
) : (
<span className="text-muted">—</span>
<span className="text-base-content/45">—</span>
)}
</dd>
</div>
</dl>
) : (
<p className="text-xs leading-relaxed text-muted">
<p className="text-xs leading-relaxed text-base-content/55">
{nego.done
? '카드 라운드 없이 조기 합의됐습니다 — 첫 제안가가 앵커가 이하면 협상 카드 없이 종료됩니다.'
? '카드 라운드 없이 조기 합의됐어요 — 첫 제안가가 앵커가 이하면 협상 카드 없이 종료됩니다.'
: '가격 협상이 시작되면 선택된 협상 카드와 가격 지표·긴장도·페르소나가 여기에 표시됩니다.'}
</p>
)}
+149
View File
@@ -0,0 +1,149 @@
import type { DemoCase } from '../content/cases'
/**
* 제안가 추이 차트 — 이 화면의 시그니처.
* 라운드마다 내려오는 제안가를 영역 차트로 그리고, 기존가·목표가·앵커가를
* 점선 기준선으로 깔아 "지금 제안이 어느 구간에 있는지" 하나만 전달한다.
*/
export function PriceChart({ demoCase, priceTrail }: { demoCase: DemoCase; priceTrail: number[] }) {
const { anchor, target, item_price } = demoCase
const W = 300
const H = 150
const PAD = { top: 14, right: 72, bottom: 12, left: 10 }
const plotW = W - PAD.left - PAD.right
const plotH = H - PAD.top - PAD.bottom
const hi = Math.max(item_price, ...(priceTrail.length ? priceTrail : [item_price]))
const lo = Math.min(anchor, ...(priceTrail.length ? priceTrail : [anchor]))
const span = (hi - lo) || 1
const yOf = (v: number) => PAD.top + (1 - (v - lo) / span) * plotH
// 첫 라운드부터 점이 왼쪽에 고정되도록 슬롯을 최소 3칸으로 유지
const slots = Math.max(priceTrail.length - 1, 3)
const xOf = (i: number) => PAD.left + (i / slots) * plotW
// 기준선 3종 — 라벨은 선 오른쪽에 두고, 세로로 가까우면 밀어내서 겹침을 막는다
const refs = [
{ v: item_price, label: '기존가', color: 'var(--color-base-content)', op: 0.4 },
{ v: target, label: '목표가', color: 'var(--color-base-content)', op: 0.75 },
{ v: anchor, label: '앵커가', color: 'var(--color-primary)', op: 1 },
]
.map((r) => ({ ...r, y: yOf(r.v), ly: yOf(r.v) }))
.sort((a, b) => a.y - b.y)
const MIN_GAP = 13
for (let i = 1; i < refs.length; i++) {
if (refs[i].ly - refs[i - 1].ly < MIN_GAP) refs[i].ly = refs[i - 1].ly + MIN_GAP
}
const overflow = refs[refs.length - 1].ly - (H - 4)
if (overflow > 0) for (const r of refs) r.ly -= overflow
const pts = priceTrail.map((v, i) => ({ x: xOf(i), y: yOf(v), v }))
const line = pts.map((p, i) => `${i === 0 ? 'M' : 'L'}${p.x},${p.y}`).join(' ')
const area = pts.length >= 2
? `${line} L${pts[pts.length - 1].x},${H - PAD.bottom} L${pts[0].x},${H - PAD.bottom} Z`
: null
const last = pts.length ? pts[pts.length - 1] : null
return (
<svg
viewBox={`0 0 ${W} ${H}`}
className="w-full"
role="img"
aria-label={
last
? `제안가 추이 — 현재 ${last.v.toLocaleString()}원, 목표가 ${target.toLocaleString()}원, 앵커가 ${anchor.toLocaleString()}원`
: `가격 기준선 — 기존가 ${item_price.toLocaleString()}원, 목표가 ${target.toLocaleString()}원, 앵커가 ${anchor.toLocaleString()}원`
}
>
<defs>
<linearGradient id="trend-fill" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stopColor="var(--color-primary)" stopOpacity="0.16" />
<stop offset="100%" stopColor="var(--color-primary)" stopOpacity="0" />
</linearGradient>
</defs>
{refs.map((r) => (
<g key={r.label}>
<line
x1={PAD.left}
y1={r.y}
x2={W - PAD.right + 6}
y2={r.y}
stroke={r.color}
strokeOpacity={r.op * 0.45}
strokeWidth="1"
strokeDasharray="3 4"
/>
<text
x={W - 2}
y={r.ly + 3}
textAnchor="end"
fontSize="9.5"
fill={r.color}
fillOpacity={Math.min(r.op + 0.2, 1)}
className="num"
>
{r.label} {r.v.toLocaleString()}
</text>
</g>
))}
{area && <path d={area} fill="url(#trend-fill)" />}
{pts.length >= 2 && (
<path
d={line}
fill="none"
stroke="var(--color-primary)"
strokeWidth="2"
strokeLinejoin="round"
strokeLinecap="round"
/>
)}
{pts.slice(0, -1).map((p, i) => (
<circle key={i} cx={p.x} cy={p.y} r="2.5" fill="var(--color-primary)" fillOpacity="0.4" />
))}
{last && (
<g>
<circle className="chart-pulse" cx={last.x} cy={last.y} r="6" fill="var(--color-primary)" />
<circle
cx={last.x}
cy={last.y}
r="4"
fill="var(--color-base-100)"
stroke="var(--color-primary)"
strokeWidth="2.5"
/>
<text
x={last.x}
y={last.y < 26 ? last.y + 18 : last.y - 10}
textAnchor={last.x > W - PAD.right - 30 ? 'end' : 'middle'}
fontSize="10.5"
fontWeight="700"
fill="var(--color-base-content)"
stroke="var(--color-base-100)"
strokeWidth="3"
paintOrder="stroke"
className="num"
>
{last.v.toLocaleString()}
</text>
</g>
)}
{!last && (
<text
x={PAD.left + plotW / 2}
y={PAD.top + plotH / 2 + 3}
textAnchor="middle"
fontSize="10.5"
fill="var(--color-base-content)"
fillOpacity="0.45"
>
첫 제안가를 입력하면 추이가 그려져요
</text>
)}
</svg>
)
}
-107
View File
@@ -1,107 +0,0 @@
import type { DemoCase } from '../content/cases'
/**
* 가격 트랙 — 이 페이지의 시그니처.
* 앵커가·목표가·기존 공급가를 한 수평 트랙에 놓고, 제안가가 내려오는 과정을 마커로 보여준다.
* 파랑 구간(앵커 이하) = 구매측 최적 · 앰버 구간(목표가 초과) = 협상 여지.
*/
export function PriceTrack({ demoCase, priceTrail }: { demoCase: DemoCase; priceTrail: number[] }) {
const { anchor, target, item_price } = demoCase
const current = priceTrail.length ? priceTrail[priceTrail.length - 1] : null
// 트랙 범위: min(앵커, 최저 제안가) 아래 여유 3% ~ max(기존가, 최고 제안가) 위 여유 3%
// (제안가가 앵커보다 낮아도 마커가 트랙 밖으로 클리핑되지 않도록 동적 확장)
const hi = Math.max(item_price, ...(priceTrail.length ? priceTrail : [item_price])) * 1.03
const lo = Math.min(anchor, ...(priceTrail.length ? priceTrail : [anchor])) * 0.97
const pos = (v: number) => Math.min(Math.max(((v - lo) / (hi - lo)) * 100, 0), 100)
// 기준선 3종 — 제안가가 범위를 크게 넓히면 서로 몰려 라벨이 겹치므로,
// 가까운 라벨(간격 < MIN_GAP%)은 아랫줄로 내려 층을 나눈다.
const MIN_GAP = 18
const ticks = [
{ value: anchor, label: '앵커가', cls: 'bg-blue' },
{ value: target, label: '목표가', cls: 'bg-ink/50' },
{ value: item_price, label: '기존가', cls: 'bg-muted/60' },
].sort((a, b) => a.value - b.value)
const rows = ticks.map(() => 0)
for (let i = 1; i < ticks.length; i++) {
let row = 0
for (let j = 0; j < i; j++) {
if (pos(ticks[i].value) - pos(ticks[j].value) < MIN_GAP && rows[j] === row) {
row += 1
j = -1 // 줄을 내렸으니 앞 라벨들과 다시 비교
}
}
rows[i] = row
}
const maxRow = Math.max(...rows)
// 가장자리에선 중앙정렬 대신 안쪽으로 붙여 패널 밖 클리핑을 막는다
const align = (p: number) =>
p <= 6
? 'translate-x-0 text-left'
: p >= 94
? '-translate-x-full text-right'
: '-translate-x-1/2 text-center'
const Tick = ({ value, label, cls, row }: { value: number; label: string; cls: string; row: number }) => (
<div className="absolute top-0 h-full" style={{ left: `${pos(value)}%` }}>
<div className={`h-full w-px ${cls}`} />
<div
className={`absolute whitespace-nowrap ${align(pos(value))}`}
style={{ top: `calc(100% + ${4 + row * 28}px)` }}
>
<div className="text-[10px] leading-tight text-muted">{label}</div>
<div className="font-mono text-[11px] font-medium leading-tight">{value.toLocaleString()}</div>
</div>
</div>
)
return (
<div>
<div
className="relative mt-6 h-3 rounded-full bg-paper"
style={{ marginBottom: `${2.25 + maxRow * 1.75}rem` }}
>
{/* 구간 채색: [lo~anchor]=파랑(최적) · [anchor~target]=연파랑(합의권) · [target~hi]=앰버(초과) */}
<div className="absolute inset-y-0 left-0 rounded-l-full bg-blue/70" style={{ width: `${pos(anchor)}%` }} />
<div
className="absolute inset-y-0 bg-blue-soft"
style={{ left: `${pos(anchor)}%`, width: `${pos(target) - pos(anchor)}%` }}
/>
<div
className="absolute inset-y-0 rounded-r-full bg-amber-soft"
style={{ left: `${pos(target)}%`, width: `${100 - pos(target)}%` }}
/>
{ticks.map((t, i) => (
<Tick key={t.label} value={t.value} label={t.label} cls={t.cls} row={rows[i]} />
))}
{/* 과거 제안 흔적 */}
{priceTrail.slice(0, -1).map((p, i) => (
<div
key={i}
className="absolute top-1/2 size-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-ink/25"
style={{ left: `${pos(p)}%` }}
/>
))}
{/* 현재 제안가 마커 */}
{current != null && (
<div
className="track-marker absolute top-1/2 -translate-x-1/2 -translate-y-1/2"
style={{ left: `${pos(current)}%` }}
>
<div className="size-4 rounded-full border-[3px] border-ink bg-white shadow-sm" />
<div className="absolute bottom-full left-1/2 mb-1.5 -translate-x-1/2 whitespace-nowrap rounded bg-ink px-1.5 py-0.5 font-mono text-[11px] font-semibold text-white">
{current.toLocaleString()}
</div>
</div>
)}
</div>
{current == null && (
<p className="text-xs text-muted">첫 제안가를 입력하면 트랙 위에 표시됩니다.</p>
)}
</div>
)
}