o2o-negosium-original/landing/app/components/sections/comparison.tsx
Haewon Kam 55e3ab02aa [fix] landing: 섹션 세로 리듬 통일 — 간격을 SectionHeading 이 소유
디자인 시스템이 색·활자만 소유하고 간격은 각 섹션 파일에 흩어져 있어,
같은 관계에 값이 여러 개 생겼다. 스크롤할 때 섹션마다 호흡이 달라지던 원인.

  eyebrow → title      12/20px      → 16px
  title → description  16/20/32px   → 20px (display 티어 32px)
  머리 → 본문          48~96px 5종  → 56px / 80px(md)
  컨트롤 → 본문        56/64px      → 48px
  리드 → CTA           56/48px      → 48px

- SectionHeading 이 리듬을 소유하고 HEADING_GAP·CONTROL_GAP·CTA_GAP·
  DISPLAY_LEAD_GAP 를 노출. 섹션 파일에서 mb-24 같은 값을 직접 쓰지 않는다.
- negotiation-demo·final-cta 가 Section/SectionHeading 을 우회해 머리를 직접
  조판하고 있었다 — 아이브로우 간격이 이 둘만 20px 이던 원인. 프리미티브로 환원.
- SectionHeading 이 eyebrow 없이도 빈 span 을 렌더해 유령 여백이 생기던 버그 수정.
- descriptionClassName 의 text-[17px] 중복 선언 제거. lead 변형이 이미 갖고 있는
  모바일 축소 단계(text-[16px] sm:text-[17px])를 지우고 있었다.
- reinforcement: text-balance 가 쉼표를 넘어 끊던 헤드라인을 <br /> 로 명시.

reinforcement 만 gap="none" 인데, 머리가 그리드 셀 안이라 마진이 상쇄되지 않아
items-center 정렬을 밀기 때문. 간격은 그리드 래퍼가 진다.

검증: tsc --noEmit 통과, 프로덕션 빌드 통과. DOM 실측으로 375/868/1440px
전 구간에서 머리→본문·eyebrow→title·컨트롤→본문 값 일치 확인.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-05 16:22:24 +09:00

178 lines
6.7 KiB
TypeScript

import { useEffect, useRef, useState } from "react"
import { AnimatePresence, motion } from "motion/react"
import { Clock, Database, Handshake, Scale, TrendingUp, UserRound, type LucideIcon } from "lucide-react"
import { Section } from "@/components/ui/section"
import { CONTROL_GAP, SectionHeading } from "@/components/ui/section-heading"
import { Typography } from "@/components/ui/typography"
import { useFadeUp } from "@/lib/motion"
/** 기존 방식 ↔ 도입 후 토글 비교 — 화면 진입 시 자동으로 오가고, 누르면 잠시 수동(8초 후 자동 재개). */
export function Comparison() {
const fadeUp = useFadeUp()
const toggleFadeUp = useFadeUp(0.1)
const [mode, setMode] = useState<Mode>("before")
// 사용자가 토글을 누르면 잠시 자동 전환 중단, 8초 무조작 시 재개
const [locked, setLocked] = useState(false)
const [inView, setInView] = useState(false)
const sectionRef = useRef<HTMLDivElement>(null)
const lockTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null)
const selectMode = (key: Mode) => {
setMode(key)
setLocked(true)
if (lockTimerRef.current) clearTimeout(lockTimerRef.current)
lockTimerRef.current = setTimeout(() => setLocked(false), 8000)
}
useEffect(() => {
const el = sectionRef.current
if (!el) return
const observer = new IntersectionObserver(([entry]) => setInView(entry.isIntersecting), { threshold: 0.35 })
observer.observe(el)
return () => {
observer.disconnect()
if (lockTimerRef.current) clearTimeout(lockTimerRef.current)
}
}, [])
useEffect(() => {
if (!inView || locked) return
const timer = setInterval(() => setMode((m) => (m === "before" ? "after" : "before")), 3000)
return () => clearInterval(timer)
}, [inView, locked])
return (
<Section id="comparison">
<motion.div {...fadeUp}>
<SectionHeading
align="center"
eyebrow="Before & After"
title="협상 방식을 바꾸면, 무엇이 달라질까요"
description="기존 가격 협상의 문제는 사람이 아니라 구조입니다."
descriptionClassName="max-w-2xl"
/>
</motion.div>
{/* 모드 토글 — 이용 가이드 탭과 같은 세그먼트 문법.
아래 간격(CONTROL_GAP)은 머리 간격보다 좁다. 토글은 자기가 조종하는
카드들과 한 덩어리로 읽혀야지, 제목에 붙으면 무엇을 바꾸는 스위치인지 흐려진다. */}
<motion.div {...toggleFadeUp} className={`flex justify-center ${CONTROL_GAP}`}>
{/* 액티브를 bg-white 로 두면 트랙(bg-fill #F0F2F8) 과 거의 같은 밝기라
멀리서 어느 쪽이 켜졌는지 안 보인다. 채움색으로 확실히 갈라준다. */}
<div className="p-1.5 bg-fill rounded-full inline-flex gap-1.5">
{MODES.map((m) => (
<button
key={m.key}
onClick={() => selectMode(m.key)}
className={`px-7 py-3 rounded-full text-[15px] font-semibold transition-colors cursor-pointer ${
mode === m.key ? "bg-primary text-white" : "text-ink-muted hover:text-ink"
}`}
>
<span>{m.label}</span>
</button>
))}
</div>
</motion.div>
<div ref={sectionRef} className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
{ITEMS.map((item, idx) => (
<CompareCard key={item.label} item={item} mode={mode} index={idx} />
))}
</div>
</Section>
)
}
type Mode = "before" | "after"
const MODES: { key: Mode; label: string }[] = [
{ key: "before", label: "기존 방식" },
{ key: "after", label: "negotium 도입 후" },
]
type CompareItem = { label: string; icon: LucideIcon; before: string; after: string }
function CompareCard({ item, mode, index }: { item: CompareItem; mode: Mode; index: number }) {
const fadeUp = useFadeUp(0.06 * (index + 1))
const active = mode === "after"
return (
<motion.div
{...fadeUp}
className={`p-7 rounded-card flex flex-col gap-5 transition-colors duration-500 ${
active ? "bg-primary-soft/60" : "bg-surface"
}`}
>
<div className="flex items-center justify-between">
<div
className={`w-11 h-11 rounded-card flex items-center justify-center transition-colors duration-500 ${
active ? "bg-primary/10 text-primary" : "bg-ink-muted/10 text-ink-muted"
}`}
>
<item.icon className="w-5 h-5" />
</div>
<Typography variant="micro" className={active ? "text-primary" : ""}>
{item.label}
</Typography>
</div>
{/* 전환 시 레이아웃 점프 방지용 최소 높이 */}
<div className="min-h-[72px]">
<AnimatePresence mode="wait">
<motion.div
key={mode}
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -8 }}
transition={{ duration: 0.28, delay: 0.05 * index }}
>
<Typography variant="small" className={active ? "text-ink font-semibold" : "text-ink-muted"}>
{active ? item.after : item.before}
</Typography>
</motion.div>
</AnimatePresence>
</div>
</motion.div>
)
}
const ITEMS: CompareItem[] = [
{
label: "거래 시간",
icon: Clock,
before: "일일 거래의 한계 — 사람의 인력과 시간만큼만 협상합니다.",
after: "24시간 연중무휴, 전 품목·전 공급사와 동시에 협상합니다.",
},
{
label: "협상 성과",
icon: TrendingUp,
before: "담당자의 역량·감정·컨디션에 따라 성과가 흔들립니다.",
after: "전략 강화 학습으로 기준선이 상승하고, 점진적으로 개선됩니다.",
},
{
label: "노하우",
icon: Database,
before: "잘 깎는 노하우가 개인의 머릿속에만 남습니다.",
after: "모든 협상이 데이터로 축적되어 다음 전략에 재활용됩니다.",
},
{
label: "사람",
icon: UserRound,
before: "반복 협상에 시간을 뺏겨 전략 업무가 계속 밀립니다.",
after: "반복 협상은 에이전트가 맡고, 담당자는 전략 구매와 대형 건에 집중합니다.",
},
{
label: "파트너 관계",
icon: Handshake,
before: "담당자마다 기준이 달라 협력사가 조건을 예측하기 어렵습니다.",
after: "에이전트가 같은 기준으로 상시 응대해 조건이 일관됩니다.",
},
{
label: "의사 결정",
icon: Scale,
before: "개인 편향과 컴플라이언스 리스크에 노출됩니다.",
after: "객관적·데이터 기반의 투명한 프로세스로 기록됩니다.",
},
]