/* eslint-disable @next/next/no-img-element -- Share card rendering requires direct img tags for html-to-image output. */ import { Star, MapPin, Zap } from "lucide-react"; import type { Restaurant, MatchType, SceneType } from "@/types"; import { getSceneConfig } from "@/lib/sceneConfig"; import ShareCardShell from "./ShareCardShell"; import type { ShareCardTheme } from "./ShareCardShell"; export interface RestaurantShareData { type: "restaurant"; restaurant: Restaurant; matchType: MatchType; matchLikes: number; userCount: number; scene?: SceneType; } function buildTheme(isUnanimous: boolean): ShareCardTheme & { accentText: string; accentBg: string } { const accentFrom = isUnanimous ? "#059669" : "#b45309"; const accentTo = isUnanimous ? "#34d399" : "#fbbf24"; return { emoji: "⚡", tagline: "别说随便 · PANIC MODE", bgColor: "#08080a", gradientBorder: `linear-gradient(160deg, ${accentFrom}, ${accentTo}40, ${accentFrom}30)`, accentLine: `linear-gradient(to right, transparent, ${accentTo}30, transparent)`, glows: [ { top: -40, right: -30, width: 160, height: 160, color: `${accentFrom}25` }, { top: 9999, right: 9999, width: 120, height: 120, color: `${accentTo}12` }, ], qrFgColor: "#08080a", accentText: isUnanimous ? "#6ee7b7" : "#fcd34d", accentBg: isUnanimous ? "rgba(16, 185, 129, 0.12)" : "rgba(245, 158, 11, 0.12)", }; } export default function RestaurantShareCard({ data, cardRef, imageDataUrl, bgDataUrl, }: { data: RestaurantShareData; cardRef: React.RefObject; imageDataUrl: string | null; bgDataUrl?: string | null; }) { const { restaurant, matchType, matchLikes, userCount, scene } = data; const isUnanimous = matchType === "unanimous"; const verb = getSceneConfig(scene ?? "eat").verb; const theme = buildTheme(isUnanimous); const { accentText, accentBg } = theme; const accentTo = isUnanimous ? "#34d399" : "#fbbf24"; // Fix the second glow position (bottom-left, not the placeholder) theme.glows[1] = { top: 9999, right: 9999, width: 120, height: 120, color: `${accentTo}12` }; return ( {/* Second glow override (bottom-left) */}
{/* Hero section */}
{isUnanimous ? "🎉" : "🏆"}
就去这{verb}!
{isUnanimous && ( )} {isUnanimous ? `默契度 100% · ${userCount}人全员一致` : `${matchLikes}/${userCount} 人选了这家`} {isUnanimous && ( )}
{/* Restaurant card */}
{imageDataUrl && ( {restaurant.name} )}
{restaurant.name}
{restaurant.category && ( {restaurant.category} )}
{restaurant.rating > 0 && ( {restaurant.rating} )} {restaurant.price && restaurant.price !== "未知" && ( {restaurant.price} )} {restaurant.distance && ( {restaurant.distance} )}
{restaurant.address && (
📍 {restaurant.address}
)} {restaurant.tag && (
{restaurant.tag .split(",") .slice(0, 4) .map((t) => ( {t.trim()} ))}
)}
); }