youtube 계정연결 기능 작업
This commit is contained in:
1 parent
cac825de19
commit
5c912e4bf8
11 files changed
+2918
-86
No files matched your search
@@ -1,103 +1,690 @@
|
||||
|
||||
import React from 'react';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
|
||||
const StatCard: React.FC<{ label: string; value: string; trend: string }> = ({ label, value, trend }) => (
|
||||
// =====================================================
|
||||
// Types
|
||||
// =====================================================
|
||||
|
||||
interface ContentMetric {
|
||||
id: string;
|
||||
label: string;
|
||||
labelEn: string;
|
||||
value: string;
|
||||
trend: number;
|
||||
trendDirection: 'up' | 'down';
|
||||
}
|
||||
|
||||
interface MonthlyData {
|
||||
month: string;
|
||||
thisYear: number;
|
||||
lastYear: number;
|
||||
}
|
||||
|
||||
interface PlatformMetric {
|
||||
id: string;
|
||||
label: string;
|
||||
value: string;
|
||||
unit?: string;
|
||||
trend: number;
|
||||
trendDirection: 'up' | 'down';
|
||||
}
|
||||
|
||||
interface PlatformData {
|
||||
platform: 'youtube' | 'instagram';
|
||||
displayName: string;
|
||||
metrics: PlatformMetric[];
|
||||
}
|
||||
|
||||
interface TopContent {
|
||||
id: string;
|
||||
title: string;
|
||||
thumbnail: string;
|
||||
platform: 'youtube' | 'instagram';
|
||||
views: string;
|
||||
engagement: string;
|
||||
date: string;
|
||||
}
|
||||
|
||||
interface AudienceData {
|
||||
ageGroups: { label: string; percentage: number }[];
|
||||
gender: { male: number; female: number };
|
||||
topRegions: { region: string; percentage: number }[];
|
||||
}
|
||||
|
||||
// =====================================================
|
||||
// Mock Data
|
||||
// =====================================================
|
||||
|
||||
const CONTENT_METRICS: ContentMetric[] = [
|
||||
{ id: 'impressions', label: '총 노출수', labelEn: 'IMPRESSIONS', value: '2.4M', trend: 12.5, trendDirection: 'up' },
|
||||
{ id: 'reach', label: '도달', labelEn: 'REACH', value: '1.8M', trend: 9.2, trendDirection: 'up' },
|
||||
{ id: 'likes', label: '좋아요', labelEn: 'LIKES', value: '158.2K', trend: 8.3, trendDirection: 'up' },
|
||||
{ id: 'comments', label: '댓글', labelEn: 'COMMENTS', value: '24.9K', trend: 2.1, trendDirection: 'down' },
|
||||
{ id: 'shares', label: '공유', labelEn: 'SHARES', value: '8.4K', trend: 15.7, trendDirection: 'up' },
|
||||
{ id: 'saves', label: '저장', labelEn: 'SAVES', value: '12.3K', trend: 22.4, trendDirection: 'up' },
|
||||
{ id: 'engagement', label: '참여율', labelEn: 'ENGAGEMENT', value: '4.8%', trend: 0.5, trendDirection: 'up' },
|
||||
{ id: 'content', label: '콘텐츠', labelEn: 'CONTENT', value: '127', trend: 4, trendDirection: 'up' },
|
||||
];
|
||||
|
||||
const MONTHLY_DATA: MonthlyData[] = [
|
||||
{ month: '1월', thisYear: 180000, lastYear: 145000 },
|
||||
{ month: '2월', thisYear: 195000, lastYear: 158000 },
|
||||
{ month: '3월', thisYear: 210000, lastYear: 172000 },
|
||||
{ month: '4월', thisYear: 185000, lastYear: 168000 },
|
||||
{ month: '5월', thisYear: 240000, lastYear: 195000 },
|
||||
{ month: '6월', thisYear: 275000, lastYear: 210000 },
|
||||
{ month: '7월', thisYear: 320000, lastYear: 235000 },
|
||||
{ month: '8월', thisYear: 295000, lastYear: 248000 },
|
||||
{ month: '9월', thisYear: 310000, lastYear: 262000 },
|
||||
{ month: '10월', thisYear: 285000, lastYear: 255000 },
|
||||
{ month: '11월', thisYear: 340000, lastYear: 278000 },
|
||||
{ month: '12월', thisYear: 380000, lastYear: 295000 },
|
||||
];
|
||||
|
||||
const PLATFORM_DATA: PlatformData[] = [
|
||||
{
|
||||
platform: 'youtube',
|
||||
displayName: 'YouTube',
|
||||
metrics: [
|
||||
{ id: 'views', label: '조회수', value: '1.25M', trend: 18.2, trendDirection: 'up' },
|
||||
{ id: 'watchTime', label: '시청 시간', value: '4,820', unit: '시간', trend: 12.5, trendDirection: 'up' },
|
||||
{ id: 'avgViewDuration', label: '평균 시청 시간', value: '3:24', trend: 5.2, trendDirection: 'up' },
|
||||
{ id: 'subscribers', label: '구독자', value: '45.2K', trend: 5.8, trendDirection: 'up' },
|
||||
{ id: 'newSubscribers', label: '신규 구독자', value: '1.2K', trend: 12.3, trendDirection: 'up' },
|
||||
{ id: 'engagement', label: '참여율', value: '4.8', unit: '%', trend: 0.3, trendDirection: 'up' },
|
||||
{ id: 'ctr', label: '클릭률 (CTR)', value: '6.2', unit: '%', trend: 1.1, trendDirection: 'up' },
|
||||
{ id: 'revenue', label: '예상 수익', value: '₩2.4M', trend: 8.5, trendDirection: 'up' },
|
||||
],
|
||||
},
|
||||
{
|
||||
platform: 'instagram',
|
||||
displayName: 'Instagram',
|
||||
metrics: [
|
||||
{ id: 'reach', label: '도달', value: '892K', trend: 22.4, trendDirection: 'up' },
|
||||
{ id: 'impressions', label: '노출', value: '1.58M', trend: 15.1, trendDirection: 'up' },
|
||||
{ id: 'profileVisits', label: '프로필 방문', value: '28.4K', trend: 18.7, trendDirection: 'up' },
|
||||
{ id: 'followers', label: '팔로워', value: '28.5K', trend: 8.2, trendDirection: 'up' },
|
||||
{ id: 'newFollowers', label: '신규 팔로워', value: '892', trend: 15.6, trendDirection: 'up' },
|
||||
{ id: 'storyViews', label: '스토리 조회', value: '156K', trend: 3.2, trendDirection: 'down' },
|
||||
{ id: 'reelPlays', label: '릴스 재생', value: '423K', trend: 45.2, trendDirection: 'up' },
|
||||
{ id: 'websiteClicks', label: '웹사이트 클릭', value: '3.2K', trend: 11.8, trendDirection: 'up' },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const TOP_CONTENT: TopContent[] = [
|
||||
{ id: '1', title: '겨울 펜션 프로모션 영상', thumbnail: 'https://picsum.photos/seed/content1/120/68', platform: 'youtube', views: '125.4K', engagement: '8.2%', date: '2025.01.15' },
|
||||
{ id: '2', title: '스테이 머뭄 소개 릴스', thumbnail: 'https://picsum.photos/seed/content2/120/68', platform: 'instagram', views: '89.2K', engagement: '12.5%', date: '2025.01.22' },
|
||||
{ id: '3', title: '신년 특가 이벤트 안내', thumbnail: 'https://picsum.photos/seed/content3/120/68', platform: 'youtube', views: '67.8K', engagement: '6.4%', date: '2025.01.08' },
|
||||
{ id: '4', title: '펜션 야경 타임랩스', thumbnail: 'https://picsum.photos/seed/content4/120/68', platform: 'instagram', views: '54.3K', engagement: '15.8%', date: '2025.01.28' },
|
||||
];
|
||||
|
||||
const AUDIENCE_DATA: AudienceData = {
|
||||
ageGroups: [
|
||||
{ label: '18-24', percentage: 12 },
|
||||
{ label: '25-34', percentage: 35 },
|
||||
{ label: '35-44', percentage: 28 },
|
||||
{ label: '45-54', percentage: 18 },
|
||||
{ label: '55+', percentage: 7 },
|
||||
],
|
||||
gender: { male: 42, female: 58 },
|
||||
topRegions: [
|
||||
{ region: '서울', percentage: 32 },
|
||||
{ region: '경기', percentage: 24 },
|
||||
{ region: '부산', percentage: 12 },
|
||||
{ region: '인천', percentage: 8 },
|
||||
{ region: '대구', percentage: 6 },
|
||||
],
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// Animation Components
|
||||
// =====================================================
|
||||
|
||||
interface AnimatedItemProps {
|
||||
children: React.ReactNode;
|
||||
index: number;
|
||||
baseDelay?: number;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const AnimatedItem: React.FC<AnimatedItemProps> = ({ children, index, baseDelay = 0, className = '' }) => {
|
||||
const [isVisible, setIsVisible] = useState(false);
|
||||
const delay = baseDelay + index * 80;
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setTimeout(() => setIsVisible(true), delay);
|
||||
return () => clearTimeout(timer);
|
||||
}, [delay]);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`transition-all duration-500 ${
|
||||
isVisible ? 'opacity-100 translate-y-0' : 'opacity-0 -translate-y-4'
|
||||
} ${className}`}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
interface AnimatedSectionProps {
|
||||
children: React.ReactNode;
|
||||
delay?: number;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const AnimatedSection: React.FC<AnimatedSectionProps> = ({ children, delay = 0, className = '' }) => {
|
||||
const [isVisible, setIsVisible] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setTimeout(() => setIsVisible(true), delay);
|
||||
return () => clearTimeout(timer);
|
||||
}, [delay]);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`transition-all duration-600 ${
|
||||
isVisible ? 'opacity-100 translate-y-0' : 'opacity-0 translate-y-6'
|
||||
} ${className}`}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// UI Components
|
||||
// =====================================================
|
||||
|
||||
const TrendIcon: React.FC<{ direction: 'up' | 'down' }> = ({ direction }) => (
|
||||
<svg
|
||||
className="stat-trend-icon"
|
||||
viewBox="0 0 12 12"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
>
|
||||
{direction === 'up' ? (
|
||||
<path d="M6 9V3M3 5l3-3 3 3" />
|
||||
) : (
|
||||
<path d="M6 3v6M3 7l3 3 3-3" />
|
||||
)}
|
||||
</svg>
|
||||
);
|
||||
|
||||
const StatCard: React.FC<ContentMetric> = ({ labelEn, value, trend, trendDirection }) => (
|
||||
<div className="stat-card">
|
||||
<span className="stat-label">{label}</span>
|
||||
<span className="stat-label">{labelEn}</span>
|
||||
<h3 className="stat-value">{value}</h3>
|
||||
<span className="stat-trend">{trend}</span>
|
||||
<div className="stat-trend-wrapper">
|
||||
<span className={`stat-trend ${trendDirection}`}>
|
||||
<TrendIcon direction={trendDirection} />
|
||||
{trendDirection === 'up' ? '+' : '-'}{Math.abs(trend)}%
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
const DashboardContent: React.FC = () => {
|
||||
const MetricCard: React.FC<PlatformMetric> = ({ label, value, unit, trend, trendDirection }) => (
|
||||
<div className="metric-card">
|
||||
<div className="metric-card-header">
|
||||
<span className="metric-card-label">{label}</span>
|
||||
</div>
|
||||
<div className="metric-card-value">
|
||||
{value}
|
||||
{unit && <span className="metric-card-unit">{unit}</span>}
|
||||
</div>
|
||||
<div className={`metric-card-trend ${trendDirection}`}>
|
||||
<TrendIcon direction={trendDirection} />
|
||||
{trendDirection === 'up' ? '+' : '-'}{Math.abs(trend)}%
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
// =====================================================
|
||||
// Chart Component with Tooltip
|
||||
// =====================================================
|
||||
|
||||
interface TooltipData {
|
||||
x: number;
|
||||
y: number;
|
||||
month: string;
|
||||
thisYear: number;
|
||||
lastYear: number;
|
||||
}
|
||||
|
||||
const formatNumber = (num: number): string => {
|
||||
if (num >= 1000000) return (num / 1000000).toFixed(1) + 'M';
|
||||
if (num >= 1000) return (num / 1000).toFixed(0) + 'K';
|
||||
return num.toString();
|
||||
};
|
||||
|
||||
const YearOverYearChart: React.FC<{ data: MonthlyData[] }> = ({ data }) => {
|
||||
const [tooltip, setTooltip] = useState<TooltipData | null>(null);
|
||||
const [isAnimated, setIsAnimated] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setTimeout(() => setIsAnimated(true), 500);
|
||||
return () => clearTimeout(timer);
|
||||
}, []);
|
||||
|
||||
const width = 1000;
|
||||
const height = 300;
|
||||
const padding = { top: 20, right: 20, bottom: 10, left: 20 };
|
||||
const chartWidth = width - padding.left - padding.right;
|
||||
const chartHeight = height - padding.top - padding.bottom;
|
||||
|
||||
const allValues = data.flatMap(d => [d.thisYear, d.lastYear]);
|
||||
const maxValue = Math.max(...allValues);
|
||||
const minValue = Math.min(...allValues);
|
||||
const yPadding = (maxValue - minValue) * 0.15;
|
||||
const yMax = maxValue + yPadding;
|
||||
const yMin = Math.max(0, minValue - yPadding);
|
||||
|
||||
const getX = (index: number) => padding.left + (index / (data.length - 1)) * chartWidth;
|
||||
const getY = (value: number) => padding.top + chartHeight - ((value - yMin) / (yMax - yMin)) * chartHeight;
|
||||
|
||||
const generateSmoothPath = (points: { x: number; y: number }[]) => {
|
||||
if (points.length < 2) return '';
|
||||
const path: string[] = [];
|
||||
for (let i = 0; i < points.length - 1; i++) {
|
||||
const p0 = points[Math.max(i - 1, 0)];
|
||||
const p1 = points[i];
|
||||
const p2 = points[i + 1];
|
||||
const p3 = points[Math.min(i + 2, points.length - 1)];
|
||||
const tension = 0.3;
|
||||
const cp1x = p1.x + (p2.x - p0.x) * tension;
|
||||
const cp1y = p1.y + (p2.y - p0.y) * tension;
|
||||
const cp2x = p2.x - (p3.x - p1.x) * tension;
|
||||
const cp2y = p2.y - (p3.y - p1.y) * tension;
|
||||
if (i === 0) path.push(`M ${p1.x} ${p1.y}`);
|
||||
path.push(`C ${cp1x} ${cp1y}, ${cp2x} ${cp2y}, ${p2.x} ${p2.y}`);
|
||||
}
|
||||
return path.join(' ');
|
||||
};
|
||||
|
||||
const thisYearPoints = data.map((d, i) => ({ x: getX(i), y: getY(d.thisYear) }));
|
||||
const lastYearPoints = data.map((d, i) => ({ x: getX(i), y: getY(d.lastYear) }));
|
||||
const thisYearPath = generateSmoothPath(thisYearPoints);
|
||||
const lastYearPath = generateSmoothPath(lastYearPoints);
|
||||
const thisYearAreaPath = `${thisYearPath} L ${getX(data.length - 1)} ${padding.top + chartHeight} L ${padding.left} ${padding.top + chartHeight} Z`;
|
||||
|
||||
const handleMouseEnter = (index: number, event: React.MouseEvent) => {
|
||||
const rect = event.currentTarget.getBoundingClientRect();
|
||||
const svgRect = (event.currentTarget.closest('svg') as SVGSVGElement)?.getBoundingClientRect();
|
||||
if (svgRect) {
|
||||
setTooltip({
|
||||
x: rect.left - svgRect.left + rect.width / 2,
|
||||
y: rect.top - svgRect.top,
|
||||
month: data[index].month,
|
||||
thisYear: data[index].thisYear,
|
||||
lastYear: data[index].lastYear,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleMouseLeave = () => setTooltip(null);
|
||||
|
||||
return (
|
||||
<div className="dashboard-container">
|
||||
<div className="dashboard-header">
|
||||
<h1 className="dashboard-title">대시보드</h1>
|
||||
<p className="dashboard-description">실시간 마케팅 퍼포먼스를 확인하세요.</p>
|
||||
</div>
|
||||
<div className="yoy-chart-wrapper">
|
||||
<svg className="yoy-chart-svg" viewBox={`0 0 ${width} ${height}`} preserveAspectRatio="none">
|
||||
<defs>
|
||||
<linearGradient id="thisYearGradient" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stopColor="#a6ffea" stopOpacity="0.25" />
|
||||
<stop offset="100%" stopColor="#a6ffea" stopOpacity="0" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
|
||||
{/* Top Stats Grid */}
|
||||
<div className="stats-grid">
|
||||
<StatCard label="TOTAL REACH" value="124.5k" trend="지난 주 12%" />
|
||||
<StatCard label="CONVERSIONS" value="3,892" trend="지난 주 8%" />
|
||||
<StatCard label="SEO SCORE" value="98/100" trend="지난 주 12%" />
|
||||
</div>
|
||||
{/* Grid lines */}
|
||||
{[0, 0.25, 0.5, 0.75, 1].map((ratio, i) => (
|
||||
<line key={i} x1={padding.left} y1={padding.top + chartHeight * ratio} x2={width - padding.right} y2={padding.top + chartHeight * ratio} stroke="white" strokeOpacity="0.05" />
|
||||
))}
|
||||
|
||||
{/* Engagement Chart Section */}
|
||||
<div className="chart-card">
|
||||
<div className="chart-header">
|
||||
<h2 className="chart-title">Engagement Overview</h2>
|
||||
<div className="chart-legend">
|
||||
<span className="chart-legend-dot"></span>
|
||||
<span className="chart-legend-text">Weekly Active</span>
|
||||
{/* Last year line (purple, dashed) */}
|
||||
<path
|
||||
d={lastYearPath}
|
||||
fill="none"
|
||||
stroke="#a682ff"
|
||||
strokeWidth="2"
|
||||
strokeLinecap="round"
|
||||
strokeDasharray="6,4"
|
||||
opacity="0.7"
|
||||
className={`chart-line-animated ${isAnimated ? 'visible' : ''}`}
|
||||
/>
|
||||
|
||||
{/* This year gradient fill */}
|
||||
<path d={thisYearAreaPath} fill="url(#thisYearGradient)" className={`chart-area-animated ${isAnimated ? 'visible' : ''}`} />
|
||||
|
||||
{/* This year line (mint, solid) */}
|
||||
<path
|
||||
d={thisYearPath}
|
||||
fill="none"
|
||||
stroke="#a6ffea"
|
||||
strokeWidth="3"
|
||||
strokeLinecap="round"
|
||||
className={`chart-line-animated ${isAnimated ? 'visible' : ''}`}
|
||||
/>
|
||||
|
||||
{/* Interactive data points */}
|
||||
{thisYearPoints.map((point, i) => (
|
||||
<g key={i}>
|
||||
{/* Invisible larger hit area */}
|
||||
<circle
|
||||
cx={point.x}
|
||||
cy={point.y}
|
||||
r="20"
|
||||
fill="transparent"
|
||||
style={{ cursor: 'pointer' }}
|
||||
onMouseEnter={(e) => handleMouseEnter(i, e)}
|
||||
onMouseLeave={handleMouseLeave}
|
||||
/>
|
||||
{/* Visible point */}
|
||||
<circle
|
||||
cx={point.x}
|
||||
cy={point.y}
|
||||
r={tooltip?.month === data[i].month ? 6 : 4}
|
||||
fill="#a6ffea"
|
||||
style={{
|
||||
filter: 'drop-shadow(0 0 6px rgba(166,255,234,0.6))',
|
||||
transition: 'r 0.2s ease',
|
||||
}}
|
||||
className={`chart-point-animated ${isAnimated ? 'visible' : ''}`}
|
||||
onMouseEnter={(e) => handleMouseEnter(i, e)}
|
||||
onMouseLeave={handleMouseLeave}
|
||||
/>
|
||||
</g>
|
||||
))}
|
||||
|
||||
{/* Animated pulsing dot on the last point */}
|
||||
<g transform={`translate(${thisYearPoints[thisYearPoints.length - 1].x}, ${thisYearPoints[thisYearPoints.length - 1].y})`}>
|
||||
<circle r="4" fill="#a6ffea">
|
||||
<animate attributeName="r" from="4" to="12" dur="2s" repeatCount="indefinite" />
|
||||
<animate attributeName="opacity" from="0.6" to="0" dur="2s" repeatCount="indefinite" />
|
||||
</circle>
|
||||
<circle r="5" fill="#a6ffea" style={{ filter: 'drop-shadow(0 0 10px rgba(166,255,234,0.8))' }} />
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
{/* Tooltip */}
|
||||
{tooltip && (
|
||||
<div
|
||||
className="chart-tooltip"
|
||||
style={{
|
||||
left: `${(tooltip.x / width) * 100}%`,
|
||||
top: `${(tooltip.y / height) * 100}%`,
|
||||
}}
|
||||
>
|
||||
<div className="chart-tooltip-title">{tooltip.month}</div>
|
||||
<div className="chart-tooltip-row">
|
||||
<span className="chart-tooltip-dot mint"></span>
|
||||
<span className="chart-tooltip-label">올해</span>
|
||||
<span className="chart-tooltip-value">{formatNumber(tooltip.thisYear)}</span>
|
||||
</div>
|
||||
<div className="chart-tooltip-row">
|
||||
<span className="chart-tooltip-dot purple"></span>
|
||||
<span className="chart-tooltip-label">작년</span>
|
||||
<span className="chart-tooltip-value">{formatNumber(tooltip.lastYear)}</span>
|
||||
</div>
|
||||
<div className="chart-tooltip-change">
|
||||
{tooltip.thisYear > tooltip.lastYear ? '↑' : '↓'} {Math.abs(((tooltip.thisYear - tooltip.lastYear) / tooltip.lastYear) * 100).toFixed(1)}%
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
<div className="chart-container">
|
||||
{/* Chart SVG */}
|
||||
<svg
|
||||
className="w-full h-full overflow-visible"
|
||||
viewBox="0 0 1000 400"
|
||||
preserveAspectRatio="none"
|
||||
>
|
||||
<defs>
|
||||
<linearGradient id="chartGradient" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stopColor="#a6ffea" stopOpacity="0.2" />
|
||||
<stop offset="100%" stopColor="#a6ffea" stopOpacity="0" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
// =====================================================
|
||||
// Icon Components
|
||||
// =====================================================
|
||||
|
||||
{/* Grid Lines */}
|
||||
{[0, 100, 200, 300, 400].map(y => (
|
||||
<line key={y} x1="0" y1={y} x2="1000" y2={y} stroke="white" strokeOpacity="0.03" strokeWidth="1" />
|
||||
))}
|
||||
const YouTubeIcon: React.FC<{ className?: string }> = ({ className }) => (
|
||||
<svg className={className || "platform-tab-icon"} viewBox="0 0 24 24" fill="currentColor">
|
||||
<path d="M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
{/* Smooth Line Path */}
|
||||
<path
|
||||
d="M0,320 C100,340 200,220 300,260 C400,300 450,140 550,180 C650,220 750,340 850,280 C950,220 1000,80 1000,80"
|
||||
fill="none"
|
||||
stroke="#a6ffea"
|
||||
strokeWidth="3"
|
||||
strokeLinecap="round"
|
||||
/>
|
||||
const InstagramIcon: React.FC<{ className?: string }> = ({ className }) => (
|
||||
<svg className={className || "platform-tab-icon"} viewBox="0 0 24 24" fill="currentColor">
|
||||
<path d="M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 1 0 0 12.324 6.162 6.162 0 0 0 0-12.324zM12 16a4 4 0 1 1 0-8 4 4 0 0 1 0 8zm6.406-11.845a1.44 1.44 0 1 0 0 2.881 1.44 1.44 0 0 0 0-2.881z" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
{/* Gradient Fill */}
|
||||
<path
|
||||
d="M0,320 C100,340 200,220 300,260 C400,300 450,140 550,180 C650,220 750,340 850,280 C950,220 1000,80 1000,80 V400 H0 Z"
|
||||
fill="url(#chartGradient)"
|
||||
/>
|
||||
// =====================================================
|
||||
// Content Components
|
||||
// =====================================================
|
||||
|
||||
{/* Pulsing Dot */}
|
||||
<g transform="translate(550, 180)">
|
||||
<circle r="5" fill="#a6ffea">
|
||||
<animate attributeName="r" from="5" to="15" dur="2s" repeatCount="indefinite" />
|
||||
<animate attributeName="opacity" from="0.6" to="0" dur="2s" repeatCount="indefinite" />
|
||||
</circle>
|
||||
<circle r="6" fill="#a6ffea" style={{ filter: 'drop-shadow(0 0 12px rgba(166,255,234,0.8))' }} />
|
||||
</g>
|
||||
const TopContentItem: React.FC<TopContent> = ({ title, thumbnail, platform, views, engagement, date }) => (
|
||||
<div className="top-content-item">
|
||||
<div className="top-content-thumbnail">
|
||||
<img src={thumbnail} alt={title} />
|
||||
<div className="top-content-platform-badge">
|
||||
{platform === 'youtube' ? <YouTubeIcon className="top-content-platform-icon" /> : <InstagramIcon className="top-content-platform-icon" />}
|
||||
</div>
|
||||
</div>
|
||||
<div className="top-content-info">
|
||||
<h4 className="top-content-title">{title}</h4>
|
||||
<div className="top-content-stats">
|
||||
<span className="top-content-stat">
|
||||
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" />
|
||||
<circle cx="12" cy="12" r="3" />
|
||||
</svg>
|
||||
{views}
|
||||
</span>
|
||||
<span className="top-content-stat">
|
||||
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
<path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z" />
|
||||
</svg>
|
||||
{engagement}
|
||||
</span>
|
||||
</div>
|
||||
<span className="top-content-date">{date}</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
{/* Floating Data Badge */}
|
||||
<div className="chart-badge">
|
||||
<div className="chart-badge-value">1,234</div>
|
||||
<div className="chart-badge-line"></div>
|
||||
const AudienceBarChart: React.FC<{ data: { label: string; percentage: number }[]; delay?: number }> = ({ data, delay = 0 }) => {
|
||||
const [isAnimated, setIsAnimated] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setTimeout(() => setIsAnimated(true), delay);
|
||||
return () => clearTimeout(timer);
|
||||
}, [delay]);
|
||||
|
||||
return (
|
||||
<div className="audience-bar-chart">
|
||||
{data.map((item, index) => (
|
||||
<div key={item.label} className="audience-bar-item">
|
||||
<span className="audience-bar-label">{item.label}</span>
|
||||
<div className="audience-bar-track">
|
||||
<div
|
||||
className="audience-bar-fill"
|
||||
style={{
|
||||
width: isAnimated ? `${item.percentage}%` : '0%',
|
||||
transitionDelay: `${index * 100}ms`,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<span className="audience-bar-value">{item.percentage}%</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
{/* X Axis Labels */}
|
||||
<div className="chart-xaxis">
|
||||
<span>Mon</span>
|
||||
<span>Tue</span>
|
||||
<span>Wed</span>
|
||||
<span>Thu</span>
|
||||
<span>Fri</span>
|
||||
<span>Sat</span>
|
||||
<span>Sun</span>
|
||||
const GenderChart: React.FC<{ male: number; female: number; delay?: number }> = ({ male, female, delay = 0 }) => {
|
||||
const [isAnimated, setIsAnimated] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setTimeout(() => setIsAnimated(true), delay);
|
||||
return () => clearTimeout(timer);
|
||||
}, [delay]);
|
||||
|
||||
return (
|
||||
<div className="gender-chart">
|
||||
<div className="gender-chart-bars">
|
||||
<div className="gender-bar male" style={{ width: isAnimated ? `${male}%` : '0%' }}>
|
||||
<span>{male}%</span>
|
||||
</div>
|
||||
<div className="gender-bar female" style={{ width: isAnimated ? `${female}%` : '0%' }}>
|
||||
<span>{female}%</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="gender-chart-labels">
|
||||
<span className="gender-label male">남성</span>
|
||||
<span className="gender-label female">여성</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// Main Component
|
||||
// =====================================================
|
||||
|
||||
const DashboardContent: React.FC = () => {
|
||||
const [selectedPlatform, setSelectedPlatform] = useState<'youtube' | 'instagram'>('youtube');
|
||||
|
||||
const currentPlatformData = PLATFORM_DATA.find(p => p.platform === selectedPlatform);
|
||||
const lastUpdated = new Date().toLocaleDateString('ko-KR', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="dashboard-container">
|
||||
{/* Header */}
|
||||
<AnimatedSection delay={0}>
|
||||
<div className="dashboard-header-row">
|
||||
<div>
|
||||
<h1 className="dashboard-title">대시보드</h1>
|
||||
<p className="dashboard-description">실시간 마케팅 퍼포먼스를 확인하세요.</p>
|
||||
</div>
|
||||
<span className="dashboard-last-updated">마지막 업데이트: {lastUpdated}</span>
|
||||
</div>
|
||||
</AnimatedSection>
|
||||
|
||||
{/* Content Performance Section */}
|
||||
<AnimatedSection delay={100} className="dashboard-section">
|
||||
<h2 className="dashboard-section-title">콘텐츠 성과</h2>
|
||||
<div className="stats-grid-8">
|
||||
{CONTENT_METRICS.map((metric, index) => (
|
||||
<AnimatedItem key={metric.id} index={index} baseDelay={200}>
|
||||
<StatCard {...metric} />
|
||||
</AnimatedItem>
|
||||
))}
|
||||
</div>
|
||||
</AnimatedSection>
|
||||
|
||||
{/* Two Column Layout */}
|
||||
<div className="dashboard-two-column">
|
||||
{/* Year over Year Growth Section */}
|
||||
<AnimatedSection delay={600}>
|
||||
<div className="yoy-chart-card">
|
||||
<div className="yoy-chart-header">
|
||||
<h2 className="dashboard-section-title">전년 대비 성장</h2>
|
||||
<div className="chart-legend-dual">
|
||||
<div className="chart-legend-item">
|
||||
<span className="chart-legend-line solid"></span>
|
||||
<span className="chart-legend-text">올해</span>
|
||||
</div>
|
||||
<div className="chart-legend-item">
|
||||
<span className="chart-legend-line dashed"></span>
|
||||
<span className="chart-legend-text">작년</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="yoy-chart-container">
|
||||
<YearOverYearChart data={MONTHLY_DATA} />
|
||||
</div>
|
||||
<div className="yoy-chart-xaxis">
|
||||
{MONTHLY_DATA.map(d => (
|
||||
<span key={d.month}>{d.month}</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</AnimatedSection>
|
||||
|
||||
{/* Top Content Section */}
|
||||
<AnimatedSection delay={700}>
|
||||
<div className="top-content-card">
|
||||
<h2 className="dashboard-section-title">인기 콘텐츠</h2>
|
||||
<div className="top-content-list">
|
||||
{TOP_CONTENT.map((content, index) => (
|
||||
<AnimatedItem key={content.id} index={index} baseDelay={800}>
|
||||
<TopContentItem {...content} />
|
||||
</AnimatedItem>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</AnimatedSection>
|
||||
</div>
|
||||
|
||||
{/* Audience Insights Section */}
|
||||
<AnimatedSection delay={1000} className="audience-section">
|
||||
<h2 className="dashboard-section-title">오디언스 인사이트</h2>
|
||||
<div className="audience-cards">
|
||||
<AnimatedItem index={0} baseDelay={1100}>
|
||||
<div className="audience-card">
|
||||
<h3 className="audience-card-title">연령대 분포</h3>
|
||||
<AudienceBarChart data={AUDIENCE_DATA.ageGroups} delay={1200} />
|
||||
</div>
|
||||
</AnimatedItem>
|
||||
<AnimatedItem index={1} baseDelay={1100}>
|
||||
<div className="audience-card">
|
||||
<h3 className="audience-card-title">성별 분포</h3>
|
||||
<GenderChart male={AUDIENCE_DATA.gender.male} female={AUDIENCE_DATA.gender.female} delay={1300} />
|
||||
</div>
|
||||
</AnimatedItem>
|
||||
<AnimatedItem index={2} baseDelay={1100}>
|
||||
<div className="audience-card">
|
||||
<h3 className="audience-card-title">상위 지역</h3>
|
||||
<AudienceBarChart data={AUDIENCE_DATA.topRegions.map(r => ({ label: r.region, percentage: r.percentage }))} delay={1400} />
|
||||
</div>
|
||||
</AnimatedItem>
|
||||
</div>
|
||||
</AnimatedSection>
|
||||
|
||||
{/* Platform Metrics Section */}
|
||||
<AnimatedSection delay={1300}>
|
||||
<div className="platform-section-card">
|
||||
<div className="platform-section-header">
|
||||
<h2 className="dashboard-section-title">플랫폼별 지표</h2>
|
||||
<div className="platform-tabs">
|
||||
<button
|
||||
className={`platform-tab ${selectedPlatform === 'youtube' ? 'active' : ''}`}
|
||||
onClick={() => setSelectedPlatform('youtube')}
|
||||
>
|
||||
<YouTubeIcon />
|
||||
YouTube
|
||||
</button>
|
||||
<button
|
||||
className={`platform-tab ${selectedPlatform === 'instagram' ? 'active' : ''}`}
|
||||
onClick={() => setSelectedPlatform('instagram')}
|
||||
>
|
||||
<InstagramIcon />
|
||||
Instagram
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="platform-metrics-grid-8">
|
||||
{currentPlatformData?.metrics.map((metric, index) => (
|
||||
<AnimatedItem key={metric.id} index={index} baseDelay={1400}>
|
||||
<MetricCard {...metric} />
|
||||
</AnimatedItem>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</AnimatedSection>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default DashboardContent;
|
||||
Reference in new issue
Block a user