feat: INFINITH Marketing Platform — Phase 1 MVP

Complete frontend reference implementation:
- Landing page (7 sections, responsive, animated)
- Marketing Intelligence Report (11 sections, VIEW Plastic Surgery demo)
- Marketing Execution Plan (8 sections, branding/channel/calendar)
- Content Studio wizard (channel → strategy → sound → generate)
- Channel Connect page (7 platform OAuth flows)
- Distribution page (YouTube publish flow)
- Performance Dashboard (KPI, funnel, heatmap, trends)
- PDF export (section-based, no mid-content splits)
- Design system (pastel palette, filled icons, Pretendard/Playfair)
- Page navigator (landing ↔ report ↔ plan)
- Asset upload (drag & drop, image/video/text)

Docs: PRD v2.0, DESIGN_SYSTEM.md, API_CONNECTORS.md

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Haewon KamandClaude Opus 4.6 committed 2026-03-24 16:48:11 +09:00
commit bbb7a0de60
90 files changed
+16754

No files matched your search

+214
View File
@@ -0,0 +1,214 @@
import { useState, useCallback } from 'react';
/**
* PDF Export Strategy:
* Instead of capturing each section as one giant canvas and slicing mid-content,
* we break each section into smaller "sub-blocks" (header, cards, rows, etc.)
* and treat each sub-block atomically — never splitting a block across pages.
*
* For sections smaller than one page: render as a single image.
* For sections taller than one page: find natural break points (child elements)
* and capture each child separately, starting a new page when needed.
*/
function collectSubBlocks(section: HTMLElement): HTMLElement[] {
// If the section is short enough to fit one page (~1200px at scale 2),
// treat the whole section as one block
if (section.offsetHeight <= 900) {
return [section];
}
// Otherwise, break into sub-blocks:
// Look for the section header (first child with dark bg or title)
// and then each subsequent child
const children = Array.from(section.children) as HTMLElement[];
if (children.length <= 1) {
return [section]; // Can't break further
}
// Group: keep section header + subtitle together as first block,
// then each remaining child as its own block
const blocks: HTMLElement[] = [];
// Find the section-level wrapper — if it has a header area and a content area
// For our SectionWrapper pattern: first child is usually the header area
for (const child of children) {
if (child.offsetHeight === 0 || child.offsetWidth === 0) continue;
blocks.push(child);
}
return blocks.length > 0 ? blocks : [section];
}
export function useExportPDF() {
const [isExporting, setIsExporting] = useState(false);
const exportPDF = useCallback(async (filename = 'INFINITH_Marketing_Intelligence_Report') => {
setIsExporting(true);
try {
const [{ default: html2canvas }, { jsPDF }] = await Promise.all([
import('html2canvas-pro'),
import('jspdf'),
]);
// 1. Force all animations to their final state
document.documentElement.style.setProperty('--motion-duration', '0s');
const animatedEls: { el: HTMLElement; origOpacity: string; origTransform: string }[] = [];
document.querySelectorAll('[style*="opacity"]').forEach((el) => {
const htmlEl = el as HTMLElement;
animatedEls.push({
el: htmlEl,
origOpacity: htmlEl.style.opacity,
origTransform: htmlEl.style.transform,
});
htmlEl.style.opacity = '1';
htmlEl.style.transform = 'none';
});
// 2. Hide UI-only elements
const hideSelectors = [
'[data-report-nav]',
'[data-plan-nav]',
'nav',
'[data-cta-card]',
'[data-no-print]',
];
const hiddenEls: HTMLElement[] = [];
hideSelectors.forEach((sel) => {
document.querySelectorAll(sel).forEach((el) => {
hiddenEls.push(el as HTMLElement);
(el as HTMLElement).style.display = 'none';
});
});
// 3. Find the content wrapper
const contentEl =
(document.querySelector('[data-report-content]') as HTMLElement) ||
(document.querySelector('[data-plan-content]') as HTMLElement);
if (!contentEl) throw new Error('Report content element not found');
// 4. Setup PDF
const pdf = new jsPDF('p', 'mm', 'a4');
const pageWidth = 210;
const pageHeight = 297;
const margin = 8;
const usableWidth = pageWidth - margin * 2;
const footerSpace = 10;
const maxContentY = pageHeight - margin - footerSpace;
let currentY = margin;
let needsNewPageForNext = false;
const sections = Array.from(contentEl.children) as HTMLElement[];
for (let sIdx = 0; sIdx < sections.length; sIdx++) {
const section = sections[sIdx];
if (section.offsetHeight === 0 || section.offsetWidth === 0) continue;
// Decide: capture whole section or break into sub-blocks
const blocks = collectSubBlocks(section);
for (let bIdx = 0; bIdx < blocks.length; bIdx++) {
const block = blocks[bIdx];
if (block.offsetHeight === 0) continue;
const canvas = await html2canvas(block, {
scale: 2,
useCORS: true,
logging: false,
backgroundColor: null, // Preserve dark section backgrounds
windowWidth: 1280,
removeContainer: true,
});
const blockHeightMM = (canvas.height * usableWidth) / canvas.width;
// Will this block fit on the current page?
if (currentY + blockHeightMM > maxContentY && currentY > margin + 5) {
// Doesn't fit — start a new page
pdf.addPage();
currentY = margin;
}
// If block is STILL taller than one full page, we must slice it
if (blockHeightMM > maxContentY - margin) {
const pxPerMM = canvas.width / usableWidth;
let srcY = 0;
let remainPx = canvas.height;
let isFirstSlice = true;
while (remainPx > 0) {
if (!isFirstSlice) {
pdf.addPage();
currentY = margin;
}
isFirstSlice = false;
const availMM = maxContentY - currentY;
const availPx = availMM * pxPerMM;
const sliceH = Math.min(remainPx, availPx);
const sliceCanvas = document.createElement('canvas');
sliceCanvas.width = canvas.width;
sliceCanvas.height = Math.ceil(sliceH);
const ctx = sliceCanvas.getContext('2d');
if (ctx) {
ctx.drawImage(
canvas,
0, srcY, canvas.width, Math.ceil(sliceH),
0, 0, canvas.width, Math.ceil(sliceH),
);
}
const sliceData = sliceCanvas.toDataURL('image/jpeg', 0.9);
const sliceMM = sliceH / pxPerMM;
pdf.addImage(sliceData, 'JPEG', margin, currentY, usableWidth, sliceMM);
currentY += sliceMM;
srcY += sliceH;
remainPx -= sliceH;
}
} else {
// Normal case: block fits on current page
const imgData = canvas.toDataURL('image/jpeg', 0.9);
pdf.addImage(imgData, 'JPEG', margin, currentY, usableWidth, blockHeightMM);
currentY += blockHeightMM;
}
}
// Small gap between sections
currentY += 2;
}
// 6. Restore hidden elements
hiddenEls.forEach((el) => { el.style.display = ''; });
animatedEls.forEach(({ el, origOpacity, origTransform }) => {
el.style.opacity = origOpacity;
el.style.transform = origTransform;
});
document.documentElement.style.removeProperty('--motion-duration');
// 7. Add page footers
const totalPages = pdf.getNumberOfPages();
for (let i = 1; i <= totalPages; i++) {
pdf.setPage(i);
pdf.setFontSize(7);
pdf.setTextColor(180);
pdf.text(
`INFINITH Marketing Intelligence Report | Page ${i} / ${totalPages}`,
pageWidth / 2,
pageHeight - 5,
{ align: 'center' },
);
}
pdf.save(`${filename}.pdf`);
} catch (err) {
console.error('PDF export failed:', err);
} finally {
setIsExporting(false);
}
}, []);
return { exportPDF, isExporting };
}
+34
View File
@@ -0,0 +1,34 @@
import { useState, useEffect } from 'react';
import type { MarketingPlan } from '../types/plan';
import { mockPlan } from '../data/mockPlan';
interface UseMarketingPlanResult {
data: MarketingPlan | null;
isLoading: boolean;
error: string | null;
}
export function useMarketingPlan(id: string | undefined): UseMarketingPlanResult {
const [data, setData] = useState<MarketingPlan | null>(null);
const [isLoading, setIsLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
if (!id) {
setError('No plan ID provided');
setIsLoading(false);
return;
}
// Phase 1: Return mock data
// Phase 2+: Replace with real API call
const timer = setTimeout(() => {
setData(mockPlan);
setIsLoading(false);
}, 100);
return () => clearTimeout(timer);
}, [id]);
return { data, isLoading, error };
}
+34
View File
@@ -0,0 +1,34 @@
import { useState, useEffect } from 'react';
import type { MarketingReport } from '../types/report';
import { mockReport } from '../data/mockReport';
interface UseReportResult {
data: MarketingReport | null;
isLoading: boolean;
error: string | null;
}
export function useReport(id: string | undefined): UseReportResult {
const [data, setData] = useState<MarketingReport | null>(null);
const [isLoading, setIsLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
if (!id) {
setError('No report ID provided');
setIsLoading(false);
return;
}
// Phase 1: Return mock data immediately
// Phase 2+: Replace with real API call — fetch(`/api/reports/${id}`)
const timer = setTimeout(() => {
setData(mockReport);
setIsLoading(false);
}, 100);
return () => clearTimeout(timer);
}, [id]);
return { data, isLoading, error };
}