Download src/components/dashboard/activity-feed.tsx from NAP1320/RotNot: direct link, hf CLI and curl.
- Browser
- Download file 2.98 kB
-
https://huggingface.co/spaces/NAP1320/RotNot/resolve/main/src/components/dashboard/activity-feed.tsx
- Command line
-
hf download hf://spaces/NAP1320/RotNot/src/components/dashboard/activity-feed.tsx
-
curl -L -o activity-feed.tsx https://huggingface.co/spaces/NAP1320/RotNot/resolve/main/src/components/dashboard/activity-feed.tsx
2.98 kB
| "use client"; | |
| import { CATEGORY_LABELS, CATEGORY_COLORS, type Category } from "@/config/xp"; | |
| import { Zap } from "lucide-react"; | |
| import { formatDistanceToNow } from "date-fns"; | |
| interface Activity { | |
| id: number; | |
| category: string; | |
| exerciseType: string; | |
| description: string | null; | |
| totalXp: number; | |
| isCriticalHit: boolean; | |
| createdAt: string; | |
| } | |
| interface ActivityFeedProps { | |
| activities: Activity[]; | |
| } | |
| export function ActivityFeed({ activities }: ActivityFeedProps) { | |
| if (activities.length === 0) { | |
| return ( | |
| <div | |
| className="text-center py-8 text-sm" | |
| style={{ color: "var(--text-muted)" }} | |
| > | |
| No activity yet — start training! | |
| </div> | |
| ); | |
| } | |
| return ( | |
| <div className="space-y-2"> | |
| {activities.map((activity) => { | |
| const cat = activity.category as Category; | |
| const color = CATEGORY_COLORS[cat] ?? "#6b7280"; | |
| const label = CATEGORY_LABELS[cat] ?? activity.category; | |
| const timeAgo = formatDistanceToNow(new Date(activity.createdAt), { | |
| addSuffix: true, | |
| }); | |
| return ( | |
| <div | |
| key={activity.id} | |
| className="flex items-center gap-3 rounded-lg px-3 py-2" | |
| style={{ background: "rgba(255,255,255,0.03)" }} | |
| > | |
| {/* Category dot */} | |
| <div | |
| className="w-2 h-2 rounded-full flex-shrink-0" | |
| style={{ background: color }} | |
| /> | |
| {/* Content */} | |
| <div className="flex-1 min-w-0"> | |
| <div className="flex items-center gap-2"> | |
| <span | |
| className="text-xs font-semibold" | |
| style={{ color, whiteSpace: "nowrap" }} | |
| > | |
| {label} | |
| </span> | |
| <span | |
| className="text-xs truncate" | |
| style={{ color: "var(--text-secondary)" }} | |
| > | |
| {activity.exerciseType} | |
| {activity.description ? ` — ${activity.description}` : ""} | |
| </span> | |
| </div> | |
| <span className="text-xs" style={{ color: "var(--text-muted)" }}> | |
| {timeAgo} | |
| </span> | |
| </div> | |
| {/* XP */} | |
| <div className="flex items-center gap-1 flex-shrink-0"> | |
| {activity.isCriticalHit && ( | |
| <Zap size={12} color="#f59e0b" fill="#f59e0b" /> | |
| )} | |
| <span | |
| className="text-sm font-bold" | |
| style={{ | |
| fontFamily: "var(--font-mono)", | |
| color: activity.isCriticalHit ? "#f59e0b" : "var(--text-primary)", | |
| }} | |
| > | |
| +{activity.totalXp} | |
| </span> | |
| <span className="text-xs" style={{ color: "var(--text-muted)" }}> | |
| XP | |
| </span> | |
| </div> | |
| </div> | |
| ); | |
| })} | |
| </div> | |
| ); | |
| } | |