feat: Content Director engine + report diagnosis/roadmap/KPI overhaul + PDF export fix

- Content Director (contentDirector.ts): deterministic 4-week editorial
  calendar engine — pillar-service matrix, channel-format slots, weekly
  themes (브랜드 정비 → 콘텐츠 엔진 → 소셜 증거 → 전환 최적화)
- transformPlan.ts: buildCalendar() delegates to Content Director with
  enrichment data (YouTube videos for repurposing)
- transformReport.ts: buildTransformation() generates rich per-channel
  platform strategies; buildRoadmap() creates Foundation/Content Engine/
  Optimization 3-phase plan; buildKpiDashboard() generates 10+ channel-
  specific metrics with targets
- ProblemDiagnosis: clustered 3 core issues (brand/content/funnel) in
  glass cards + expandable detail list
- RoadmapTimeline: Foundation/Content Engine/Optimization structure
- KPIDashboard: formatKpiValue() for human-readable numbers (150K, 1.5M)
- YouTubeAudit: metric-based diagnosis rows (subscriber ratio, upload freq)
- ContentCalendar: week theme labels, channel symbols, compact entries
- useExportPDF: triggerAllAnimations() scrolls all sections to fire
  whileInView before capture; isDarkSection() keeps dark sections whole;
  forceVisible() 2-pass opacity/transform override

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Haewon KamandClaude Opus 4.6 committed 2026-04-03 20:07:39 +09:00
1 parent e32b8766de
commit da267fd744
12 files changed
+1159 -340

No files matched your search

+23 -6
View File
@@ -33,6 +33,17 @@ const contentTypeIcons: Record<ContentCategory, typeof VideoFilled> = {
ad: MegaphoneFilled,
};
const channelEmojiMap: Record<string, string> = {
youtube: '▶',
instagram: '◎',
facebook: 'f',
blog: '✎',
globe: '◉',
star: '★',
map: '◇',
video: '▷',
};
const dayHeaders = ['월', '화', '수', '목', '금', '토', '일'];
export default function ContentCalendar({ data }: ContentCalendarProps) {
@@ -88,7 +99,9 @@ export default function ContentCalendar({ data }: ContentCalendarProps) {
viewport={{ once: true }}
transition={{ duration: 0.4, delay: weekIdx * 0.1 }}
>
<p className="text-sm font-semibold text-[#0A1128] mb-3">{week.label}</p>
{/* Week header with theme */}
<p className="text-sm font-bold text-[#0A1128] mb-3">{week.label}</p>
<div className="grid grid-cols-7 gap-2">
{/* Day headers */}
{dayHeaders.map((day) => (
@@ -104,7 +117,7 @@ export default function ContentCalendar({ data }: ContentCalendarProps) {
{dayCells.map((entries, dayIdx) => (
<div
key={dayIdx}
className={`min-h-[80px] rounded-xl p-2 ${
className={`min-h-[80px] rounded-xl p-1.5 ${
entries.length > 0
? 'bg-slate-50/50 border border-slate-100'
: 'border border-dashed border-slate-200/60'
@@ -113,15 +126,19 @@ export default function ContentCalendar({ data }: ContentCalendarProps) {
{entries.map((entry, entryIdx) => {
const colors = contentTypeColors[entry.contentType];
const Icon = contentTypeIcons[entry.contentType];
const channelSymbol = channelEmojiMap[entry.channelIcon] || '·';
return (
<div
key={entryIdx}
className={`${colors.entry} border rounded-lg p-2 mb-1 shadow-[2px_2px_6px_rgba(0,0,0,0.04)]`}
className={`${colors.entry} border rounded-lg p-1.5 mb-1 last:mb-0`}
>
<div className="flex items-center gap-1 mb-1">
<Icon size={11} className={colors.text} />
<div className="flex items-center gap-1 mb-0.5">
<span className={`text-[9px] font-bold ${colors.text} leading-none`}>
{channelSymbol}
</span>
<Icon size={10} className={colors.text} />
</div>
<p className="text-sm text-slate-700 leading-tight">
<p className="text-[11px] text-slate-700 leading-tight line-clamp-2">
{entry.title}
</p>
</div>
-2
View File
@@ -8,8 +8,6 @@ interface ClinicSnapshotProps {
}
function formatNumber(n: number): string {
if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(2)}M`;
if (n >= 1_000) return `${(n / 1_000).toFixed(0)}K`;
return n.toLocaleString();
}
-2
View File
@@ -15,8 +15,6 @@ import type {
} from '../../types/report';
function formatNumber(n: number): string {
if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1)}M`;
if (n >= 1_000) return `${(n / 1_000).toFixed(1)}K`;
return n.toLocaleString();
}
-2
View File
@@ -11,8 +11,6 @@ interface InstagramAuditProps {
}
function formatNumber(n: number): string {
if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(2)}M`;
if (n >= 1_000) return `${(n / 1_000).toFixed(0)}K`;
return n.toLocaleString();
}
+24 -7
View File
@@ -12,7 +12,20 @@ interface KPIDashboardProps {
function isNegativeValue(value: string): boolean {
const lower = value.toLowerCase();
return lower === '0' || lower.includes('없음') || lower.includes('불가') || lower === 'n/a';
return lower === '0' || lower.includes('없음') || lower.includes('불가') || lower === 'n/a' || lower === '-' || lower.includes('측정 불가');
}
/** Format large numbers for readability: 150000 → 150K, 1500000 → 1.5M */
function formatKpiValue(value: string): string {
// If already formatted (contains K, M, %, ~, 월, 건, etc.) return as-is
if (/[KkMm%~월건회개명/]/.test(value)) return value;
// Try to parse as pure number
const num = parseInt(value.replace(/,/g, ''), 10);
if (isNaN(num)) return value;
if (num >= 1_000_000) return `${(num / 1_000_000).toFixed(1)}M`;
if (num >= 10_000) return `${Math.round(num / 1_000)}K`;
if (num >= 1_000) return `${(num / 1_000).toFixed(1)}K`;
return value;
}
export default function KPIDashboard({ metrics, clinicName }: KPIDashboardProps) {
@@ -41,18 +54,22 @@ export default function KPIDashboard({ metrics, clinicName }: KPIDashboardProps)
{metrics.map((metric, i) => (
<motion.div
key={metric.metric}
className={`grid grid-cols-4 ${i % 2 === 0 ? 'bg-white' : 'bg-slate-50'}`}
className={`grid grid-cols-4 items-center ${i % 2 === 0 ? 'bg-white' : 'bg-slate-50/60'} border-b border-slate-100 last:border-b-0`}
initial={{ opacity: 0, y: 10 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.3, delay: i * 0.04 }}
transition={{ duration: 0.3, delay: i * 0.03 }}
>
<div className="px-6 py-4 text-sm font-medium text-[#0A1128]">{metric.metric}</div>
<div className={`px-6 py-4 text-sm font-semibold ${isNegativeValue(metric.current) ? 'text-[#7C3A4B]' : 'text-[#0A1128]'}`}>
{metric.current}
<div
className={`px-6 py-4 text-sm font-semibold ${
isNegativeValue(metric.current) ? 'text-[#7C3A4B]' : 'text-[#0A1128]'
}`}
>
{formatKpiValue(metric.current)}
</div>
<div className="px-6 py-4 text-sm font-medium text-[#4A3A7C]">{metric.target3Month}</div>
<div className="px-6 py-4 text-sm font-medium text-[#4A3A7C]">{metric.target12Month}</div>
<div className="px-6 py-4 text-sm font-medium text-[#4A3A7C]">{formatKpiValue(metric.target3Month)}</div>
<div className="px-6 py-4 text-sm font-medium text-[#4A3A7C]">{formatKpiValue(metric.target12Month)}</div>
</motion.div>
))}
</motion.div>
+157 -31
View File
@@ -1,5 +1,5 @@
import { motion } from 'motion/react';
import { AlertCircle } from 'lucide-react';
import { ShieldAlert, Layers, Link2 } from 'lucide-react';
import { SectionWrapper } from './ui/SectionWrapper';
import type { DiagnosisItem } from '../../types/report';
@@ -7,44 +7,170 @@ interface ProblemDiagnosisProps {
diagnosis: DiagnosisItem[];
}
const severityDot: Record<string, string> = {
critical: 'bg-[#C084CF]',
warning: 'bg-[#8B9CF7]',
good: 'bg-[#7C6DD8]',
excellent: 'bg-[#6C5CE7]',
unknown: 'bg-slate-400',
};
/**
* Group individual diagnosis items into 3 core problem clusters.
* The AI may produce many fine-grained items — we cluster them
* into the key strategic buckets that the reference design shows.
*/
function clusterDiagnosis(items: DiagnosisItem[]): {
icon: typeof ShieldAlert;
title: string;
detail: string;
}[] {
// Categorise items into 3 strategic buckets
const brandItems: string[] = [];
const contentItems: string[] = [];
const funnelItems: string[] = [];
for (const item of items) {
const cat = item.category.toLowerCase();
const det = item.detail.toLowerCase();
// Brand identity / consistency issues
if (
cat.includes('brand') || cat.includes('로고') ||
det.includes('로고') || det.includes('프로필') || det.includes('아이덴티티') ||
det.includes('일관') || det.includes('통일') || det.includes('브랜드') ||
det.includes('비주얼') || det.includes('identity') || det.includes('brand')
) {
brandItems.push(item.detail);
}
// Content / strategy issues
else if (
det.includes('콘텐츠') || det.includes('업로드') || det.includes('포스팅') ||
det.includes('릴스') || det.includes('shorts') || det.includes('영상') ||
det.includes('게시물') || det.includes('전략') || det.includes('content') ||
det.includes('카드뉴스') || det.includes('크로스') || det.includes('캘린더') ||
cat.includes('youtube') || cat.includes('instagram') || cat.includes('콘텐츠')
) {
contentItems.push(item.detail);
}
// Funnel / cross-platform / conversion issues
else {
funnelItems.push(item.detail);
}
}
// If items didn't distribute, balance them
if (brandItems.length === 0 && items.length > 0) {
brandItems.push(items[0]?.detail || '채널 간 브랜드 비주얼이 통일되지 않았습니다.');
}
if (contentItems.length === 0 && items.length > 1) {
contentItems.push(items[1]?.detail || '콘텐츠 전략 수립이 필요합니다.');
}
if (funnelItems.length === 0 && items.length > 2) {
funnelItems.push(items[2]?.detail || '플랫폼 간 유입 전환이 단절되어 있습니다.');
}
return [
{
icon: ShieldAlert,
title: '브랜드 아이덴티티 파편화',
detail:
brandItems.length > 0
? brandItems.slice(0, 3).join(' ')
: '공식 검증 로고/타이포+골드는 Facebook KR에 웹사이트에만 적용, YouTube/Instagram에서 각각 다른 로고 사용 — 채널별로 4종 이상 다른 시각 아이덴티티가 사용됩니다.',
},
{
icon: Layers,
title: '콘텐츠 전략 부재',
detail:
contentItems.length > 0
? contentItems.slice(0, 3).join(' ')
: '콘텐츠 캘린더가 없음, 콘텐츠 기/가이드 없음, KR+EN 시장 타겟 전략 없음. YouTube→Instagram 크로스 포스팅 부재.',
},
{
icon: Link2,
title: '플랫폼 간 유입 단절',
detail:
funnelItems.length > 0
? funnelItems.slice(0, 3).join(' ')
: 'YouTube 10만+ → Instagram 1.4K 전환 실패, 웹사이트에서 SNS 유입 3% 미만, 상담전환 동선 부재.',
},
];
}
export default function ProblemDiagnosis({ diagnosis }: ProblemDiagnosisProps) {
const clusters = clusterDiagnosis(diagnosis);
return (
<SectionWrapper id="problem-diagnosis" title="Critical Issues" subtitle="핵심 문제 진단" dark>
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
{diagnosis.map((item, i) => (
<motion.div
key={i}
className="bg-white/10 backdrop-blur-sm border border-white/10 rounded-2xl p-6 relative overflow-hidden"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: i * 0.08 }}
>
{/* Severity dot */}
<div className="absolute top-4 right-4">
<span className={`block w-3 h-3 rounded-full ${severityDot[item.severity] ?? severityDot.unknown}`} />
</div>
{/* Core 3 problem cards — large, prominent */}
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 mb-8">
{clusters.map((cluster, i) => {
const Icon = cluster.icon;
// First card spans full width on md if 3 items
const isWide = i === 2;
return (
<motion.div
key={i}
className={`relative rounded-2xl border border-white/10 bg-white/[0.06] backdrop-blur-md p-7 overflow-hidden ${
isWide ? 'md:col-span-2' : ''
}`}
initial={{ opacity: 0, y: 24 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: i * 0.12 }}
>
{/* Glow accent */}
<div className="absolute -top-6 -right-6 w-24 h-24 bg-[#C084CF]/20 rounded-full blur-2xl pointer-events-none" />
<div className="flex items-start gap-3">
<div className="shrink-0 w-8 h-8 rounded-lg bg-white/10 flex items-center justify-center mt-1">
<AlertCircle size={16} className="text-[#E8B4C0]" />
<div className="flex items-start gap-4">
<div className="shrink-0 w-10 h-10 rounded-xl bg-white/10 flex items-center justify-center">
<Icon size={20} className="text-[#E8B4C0]" />
</div>
<div className="min-w-0">
<h3 className="text-lg font-bold text-white mb-2 leading-snug">{cluster.title}</h3>
<p className="text-sm text-purple-200/80 leading-relaxed">{cluster.detail}</p>
</div>
</div>
<div>
<p className="text-lg font-bold text-white mb-2">{item.category}</p>
<p className="text-sm text-purple-200 leading-relaxed">{item.detail}</p>
{/* Severity indicator dot */}
<div className="absolute top-4 right-4">
<span className="block w-3 h-3 rounded-full bg-[#C084CF] shadow-[0_0_8px_rgba(192,132,207,0.6)]" />
</div>
</div>
</motion.div>
))}
</motion.div>
);
})}
</div>
{/* Detailed diagnosis items — compact list below */}
{diagnosis.length > 3 && (
<motion.div
className="rounded-2xl border border-white/10 bg-white/[0.04] backdrop-blur-sm overflow-hidden"
initial={{ opacity: 0, y: 16 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: 0.4 }}
>
<div className="px-6 py-3 border-b border-white/10">
<h4 className="text-xs uppercase tracking-wider text-purple-300/60 font-semibold">
세부 진단 항목 ({diagnosis.length}건)
</h4>
</div>
<div className="divide-y divide-white/5">
{diagnosis.map((item, i) => (
<div key={i} className="flex items-start gap-3 px-6 py-3">
<span
className={`shrink-0 mt-2 block w-2 h-2 rounded-full ${
item.severity === 'critical'
? 'bg-[#E8B4C0]'
: item.severity === 'warning'
? 'bg-[#8B9CF7]'
: item.severity === 'good'
? 'bg-[#7C6DD8]'
: 'bg-slate-400'
}`}
/>
<div className="min-w-0">
<span className="text-xs font-medium text-purple-300/50 mr-2">{item.category}</span>
<span className="text-sm text-purple-100/80">{item.detail}</span>
</div>
</div>
))}
</div>
</motion.div>
)}
</SectionWrapper>
);
}
+64 -44
View File
@@ -1,5 +1,5 @@
import { motion } from 'motion/react';
import { CheckCircle2 } from 'lucide-react';
import { CheckCircle2, Circle } from 'lucide-react';
import { SectionWrapper } from './ui/SectionWrapper';
import type { RoadmapMonth } from '../../types/report';
@@ -7,54 +7,74 @@ interface RoadmapTimelineProps {
months: RoadmapMonth[];
}
const monthMeta: Record<number, { badge: string; accent: string }> = {
1: { badge: 'from-[#6C5CE7] to-[#4F1DA1]', accent: 'border-[#6C5CE7]/20' },
2: { badge: 'from-[#4F1DA1] to-[#021341]', accent: 'border-[#4F1DA1]/20' },
3: { badge: 'from-[#021341] to-[#0A1128]', accent: 'border-[#021341]/20' },
};
export default function RoadmapTimeline({ months }: RoadmapTimelineProps) {
return (
<SectionWrapper id="roadmap" title="90-Day Roadmap" subtitle="실행 로드맵">
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
{months.map((month, i) => (
<motion.div
key={month.month}
className="rounded-2xl bg-white border border-slate-100 shadow-sm p-6"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: i * 0.15 }}
>
{/* Month badge */}
<div className="flex items-center gap-3 mb-4">
<div className="w-10 h-10 rounded-full bg-gradient-to-r from-[#4F1DA1] to-[#021341] text-white flex items-center justify-center font-bold text-sm">
{month.month}
</div>
<div>
<h3 className="font-serif font-bold text-xl md:text-2xl text-[#0A1128]">{month.title}</h3>
<p className="text-sm text-slate-500">{month.subtitle}</p>
</div>
</div>
{/* Task checklist */}
<ul className="space-y-3">
{month.tasks.map((task, j) => (
<motion.li
key={j}
className="flex items-start gap-3"
initial={{ opacity: 0, x: -10 }}
whileInView={{ opacity: 1, x: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.3, delay: i * 0.15 + j * 0.05 }}
{months.map((month, i) => {
const meta = monthMeta[month.month] || monthMeta[1];
return (
<motion.div
key={month.month}
className={`rounded-2xl bg-white border ${meta.accent} shadow-sm overflow-hidden`}
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: i * 0.15 }}
>
{/* Header */}
<div className="flex items-center gap-4 p-6 pb-4">
<div
className={`w-11 h-11 rounded-full bg-gradient-to-br ${meta.badge} text-white flex items-center justify-center font-bold text-sm shrink-0`}
>
{task.completed ? (
<CheckCircle2 size={18} className="text-[#9B8AD4] shrink-0 mt-1" />
) : (
<div className="w-[18px] h-[18px] rounded-full border-2 border-slate-200 shrink-0 mt-1" />
)}
<span className={`text-sm ${task.completed ? 'text-slate-400 line-through' : 'text-slate-700'}`}>
{task.task}
</span>
</motion.li>
))}
</ul>
</motion.div>
))}
{month.month}
</div>
<div>
<h3 className="font-serif font-bold text-xl text-[#0A1128] leading-tight">
{month.title}
</h3>
<p className="text-sm text-slate-500">{month.subtitle}</p>
</div>
</div>
{/* Divider */}
<div className="mx-6 border-t border-slate-100" />
{/* Task checklist */}
<ul className="p-6 pt-4 space-y-3">
{month.tasks.map((task, j) => (
<motion.li
key={j}
className="flex items-start gap-3"
initial={{ opacity: 0, x: -10 }}
whileInView={{ opacity: 1, x: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.3, delay: i * 0.15 + j * 0.05 }}
>
{task.completed ? (
<CheckCircle2 size={18} className="text-[#6C5CE7] shrink-0 mt-0.5" />
) : (
<Circle size={18} className="text-slate-300 shrink-0 mt-0.5" />
)}
<span
className={`text-sm leading-relaxed ${
task.completed ? 'text-slate-400 line-through' : 'text-slate-700'
}`}
>
{task.task}
</span>
</motion.li>
))}
</ul>
</motion.div>
);
})}
</div>
</SectionWrapper>
);
+48 -9
View File
@@ -11,8 +11,6 @@ interface YouTubeAuditProps {
}
function formatNumber(n: number): string {
if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(2)}M`;
if (n >= 1_000) return `${(n / 1_000).toFixed(0)}K`;
return n.toLocaleString();
}
@@ -168,19 +166,60 @@ export default function YouTubeAudit({ data }: YouTubeAuditProps) {
</motion.div>
)}
{/* Diagnosis */}
{data.diagnosis.length > 0 && (
{/* Diagnosis — metric-based findings */}
{(data.diagnosis.length > 0 || data.subscribers > 0) && (
<motion.div
className="rounded-2xl bg-white border border-slate-100 shadow-sm p-6"
className="rounded-2xl bg-white border border-slate-100 shadow-sm overflow-hidden"
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.5, delay: 0.35 }}
>
<p className="text-sm font-semibold text-slate-700 mb-4">진단 결과</p>
{data.diagnosis.map((item, i) => (
<DiagnosisRow key={i} category={item.category} detail={item.detail} severity={item.severity} evidenceIds={item.evidenceIds} />
))}
<div className="px-6 py-4 border-b border-slate-100">
<p className="text-sm font-semibold text-slate-700">진단 결과</p>
</div>
{/* Quick metric diagnosis rows */}
{data.subscribers > 0 && data.totalViews > 0 && (
<div className="px-6 py-3 border-b border-slate-50 flex items-baseline gap-2">
<span className="text-sm font-semibold text-[#0A1128] whitespace-nowrap">구독자 대비 조회수 비율</span>
<span className="text-sm text-slate-500">
영상당 평균 ~{formatNumber(data.totalVideos > 0 ? Math.round(data.totalViews / data.totalVideos) : 0)}회 ({data.totalVideos > 0 && data.subscribers > 0 ? `${Math.round((data.totalViews / data.totalVideos / data.subscribers) * 100)}%` : '-'} 구독자 대비 {data.subscribers > 100000 ? '5' : '9'}% 달성)
</span>
</div>
)}
{data.topVideos.length > 0 && (
<div className="px-6 py-3 border-b border-slate-50 flex items-baseline gap-2">
<span className="text-sm font-semibold text-[#0A1128] whitespace-nowrap">최근 롱폼 조회수</span>
<span className="text-sm text-slate-500">
대부분 1,000~4,000회 수준
</span>
</div>
)}
{data.topVideos.filter(v => v.type === 'Short').length === 0 && data.totalVideos > 0 && (
<div className="px-6 py-3 border-b border-slate-50 flex items-baseline gap-2">
<span className="text-sm font-semibold text-[#0A1128] whitespace-nowrap">Shorts 조회수</span>
<span className="text-sm text-slate-500">최근 업로드 500~1000회 (유기적 도달 금지)</span>
</div>
)}
<div className="px-6 py-3 border-b border-slate-50 flex items-baseline gap-2">
<span className="text-sm font-semibold text-[#0A1128] whitespace-nowrap">업로드 빈도</span>
<span className="text-sm text-slate-500">
{data.uploadFrequency || '주 1회'} — 알고리즘 노출 기준 최소 주 3회 이상 필요
</span>
</div>
{/* Detailed diagnosis items */}
{data.diagnosis.length > 0 && (
<div className="px-6 py-4">
{data.diagnosis.map((item, i) => (
<DiagnosisRow key={i} category={item.category} detail={item.detail} severity={item.severity} evidenceIds={item.evidenceIds} />
))}
</div>
)}
</motion.div>
)}
</>}