From a7846ecb61f7cb1b645d26ffeb709169fda4b2b2 Mon Sep 17 00:00:00 2001 From: Caihaohan Date: Tue, 27 Jan 2026 20:15:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20CloudWord=20?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../keyword-cloud/components/CloudWord.tsx | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 src/app/[locale]/keyword-cloud/components/CloudWord.tsx diff --git a/src/app/[locale]/keyword-cloud/components/CloudWord.tsx b/src/app/[locale]/keyword-cloud/components/CloudWord.tsx new file mode 100644 index 0000000..8d58f81 --- /dev/null +++ b/src/app/[locale]/keyword-cloud/components/CloudWord.tsx @@ -0,0 +1,112 @@ +'use client'; + +import React from 'react'; +import { cn } from '@/lib/utils'; + +interface VisualConfig { + color: 'primary' | 'secondary' | 'accent' | 'gray'; + size: string; + border: string; + rotation?: string; +} + +interface KeywordData { + id: number; + word: string; + trendScore: number; + description: string; + detailPoints: string[]; + visualConfig: VisualConfig; +} + +interface CloudWordProps { + data: KeywordData; +} + +// 颜色映射 +const colorMap: Record = { + primary: 'bg-primary', + secondary: 'bg-secondary', + accent: 'bg-accent', + gray: 'bg-gray-100 dark:bg-gray-700', +}; + +export function CloudWord({ data }: CloudWordProps) { + const { word, visualConfig, description, detailPoints } = data; + const { color, size, border, rotation } = visualConfig; + const colorClass = colorMap[color]; + + return ( + + {word} + + + ); +} + +interface WordPopoverProps { + title: string; + description: string; + points: string[]; + titleColor: string; +} + +function WordPopover({ title, description, points, titleColor }: WordPopoverProps) { + const titleColorClass = colorMap[titleColor] || 'bg-gray-100'; + + return ( +
+ {/* 标题栏 */} +
+ {title} +
+ + {/* 内容区域 */} +
+
+ + {description} +
+ {points.map((point, i) => ( +
+ + {point} +
+ ))} +
+ + {/* 箭头 */} +
+
+ ); +}