feat(web): Story-Overlays und Text-Storys im Web-Viewer anzeigen

Web zeigt Story-Editor-Inhalte nur an (Entscheidung: kein Web-Editor):
StoryOverlayLayer mit gleicher Geometrie/Groessen wie die App, Text-Storys
mit Farbverlauf, Markierungen fuehren ins Tierprofil, Notschalter beachtet.
Mitteilungen STORY_MENTION/COMMENT/REACTION, Hinweistexte: Follower-
Sichtbarkeit regelt jetzt auch das Markieren.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-10-04 16:47:25 +02:00
1 parent 5ffa472da0
commit 5676065400
5 files changed
+297 -10

No files matched your search

+7 -4
View File
@@ -483,7 +483,10 @@
"typePetSuggestion": "könnte dir gefallen",
"typeReferralJoined": "ist über deine Einladung zu PawFeed gekommen",
"typeReferralRankUp": "Du hast einen neuen Empfehlungsrang erreicht. Schau ihn dir an!",
"typeVaccineDue": "💉 Die Impfung „{name}“ ist am {date} fällig – Zeit, einen Termin zu vereinbaren."
"typeVaccineDue": "💉 Die Impfung „{name}“ ist am {date} fällig – Zeit, einen Termin zu vereinbaren.",
"typeStoryMention": "hat dich in einer Story markiert.",
"typeStoryComment": "hat deine Story kommentiert.",
"typeStoryReaction": "hat deiner Story eine Pfote gegeben."
},
"PhotoPostForm": {
"captionPlaceholder": "Bildunterschrift schreiben…",
@@ -669,9 +672,9 @@
"onlyMe": "Nur ich",
"followerVisibilitySaved": "Follower-Sichtbarkeit gespeichert",
"followerVisibilitySaveFailed": "Follower-Sichtbarkeit konnte nicht gespeichert werden",
"followerEveryoneHint": "Jeder kann die Follower- und Folgt-Listen von {name} sehen.",
"followerFollowersOnlyHint": "Nur Tiere, die {name} folgen, können die Follower- und Folgt-Listen sehen.",
"followerNobodyHint": "Nur du kannst die Follower- und Folgt-Listen von {name} sehen.",
"followerEveryoneHint": "Jeder kann die Follower- und Folgt-Listen von {name} sehen und {name} in Storys markieren.",
"followerFollowersOnlyHint": "Nur Tiere, die {name} folgen, können die Follower- und Folgt-Listen sehen und {name} in Storys markieren.",
"followerNobodyHint": "Nur du kannst die Follower- und Folgt-Listen von {name} sehen — markieren in Storys kann {name} niemand.",
"verificationHeading": "Verifizierung",
"verifiedStatus": "Dieses Tier ist verifiziert.",
"pendingStatus": "Dein Verifizierungsantrag wird noch geprüft.",
+7 -4
View File
@@ -483,7 +483,10 @@
"typePetSuggestion": "might be a good match",
"typeReferralJoined": "joined PawFeed through your invite",
"typeReferralRankUp": "You reached a new referral rank. Take a look!",
"typeVaccineDue": "💉 The \"{name}\" vaccination is due on {date} – time to book an appointment."
"typeVaccineDue": "💉 The \"{name}\" vaccination is due on {date} – time to book an appointment.",
"typeStoryMention": "tagged you in a story.",
"typeStoryComment": "commented on your story.",
"typeStoryReaction": "gave your story a paw."
},
"PhotoPostForm": {
"captionPlaceholder": "Write a caption…",
@@ -669,9 +672,9 @@
"onlyMe": "Only me",
"followerVisibilitySaved": "Follower privacy setting saved",
"followerVisibilitySaveFailed": "Failed to save follower privacy setting",
"followerEveryoneHint": "Anyone can see {name}'s followers and following lists.",
"followerFollowersOnlyHint": "Only pets that follow {name} can see the followers and following lists.",
"followerNobodyHint": "Only you can see {name}'s followers and following lists.",
"followerEveryoneHint": "Anyone can see {name}'s followers and following lists and tag {name} in stories.",
"followerFollowersOnlyHint": "Only pets that follow {name} can see the followers and following lists and tag {name} in stories.",
"followerNobodyHint": "Only you can see {name}'s followers and following lists — nobody can tag {name} in stories.",
"verificationHeading": "Verification",
"verifiedStatus": "This pet is verified.",
"pendingStatus": "Your verification request is pending review.",
+13 -2
View File
@@ -3,7 +3,7 @@
import { useEffect, useState } from "react";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { Bell, UserPlus, Heart, MessageCircle, Cake, Home, AtSign, Repeat2, Sparkles, Gift, Award, Syringe } from "lucide-react";
import { Bell, UserPlus, Heart, MessageCircle, Cake, Home, AtSign, Repeat2, Sparkles, Gift, Award, Syringe, PawPrint } from "lucide-react";
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
import { useTRPC } from "@/trpc/client";
import { useActivePet } from "@/context/ActivePetContext";
@@ -17,7 +17,7 @@ import { useLocale, useTranslations } from "next-intl";
import { formatRelativeCompact } from "@/lib/format-relative-time";
import { RankRing } from "@/components/referrals/RankRing";
type NotificationType = "FOLLOW" | "REACTION" | "COMMENT" | "MESSAGE" | "BIRTHDAY" | "ADOPTION_DAY" | "MENTION" | "PAW_BACK" | "PET_SUGGESTION" | "REFERRAL_JOINED" | "REFERRAL_RANK_UP" | "VACCINE_DUE";
type NotificationType = "FOLLOW" | "REACTION" | "COMMENT" | "MESSAGE" | "BIRTHDAY" | "ADOPTION_DAY" | "MENTION" | "PAW_BACK" | "PET_SUGGESTION" | "REFERRAL_JOINED" | "REFERRAL_RANK_UP" | "VACCINE_DUE" | "STORY_MENTION" | "STORY_COMMENT" | "STORY_REACTION";
function notificationIcon(type: NotificationType) {
switch (type) {
@@ -33,6 +33,9 @@ function notificationIcon(type: NotificationType) {
case "REFERRAL_JOINED": return <Gift className="h-4 w-4 text-orange-500" />;
case "REFERRAL_RANK_UP": return <Award className="h-4 w-4 text-orange-500" />;
case "VACCINE_DUE": return <Syringe className="h-4 w-4 text-sky-500" />;
case "STORY_MENTION": return <AtSign className="h-4 w-4 text-orange-500" />;
case "STORY_COMMENT": return <MessageCircle className="h-4 w-4 text-orange-500" />;
case "STORY_REACTION": return <PawPrint className="h-4 w-4 text-orange-500" />;
}
}
@@ -100,6 +103,11 @@ export default function NotificationsPage() {
return notif.actorPet ? `/pets/${notif.actorPet.id}` : null;
case "REFERRAL_RANK_UP":
return "/einladen";
// Story-Mitteilungen → Tierprofil (dort läuft die Story über den Ring)
case "STORY_MENTION":
case "STORY_COMMENT":
case "STORY_REACTION":
return notif.story ? `/pets/${notif.story.petId}` : null;
case "BIRTHDAY":
case "ADOPTION_DAY":
case "VACCINE_DUE":
@@ -240,6 +248,9 @@ export default function NotificationsPage() {
{notif.type === "PET_SUGGESTION" && t("typePetSuggestion")}
{notif.type === "REFERRAL_JOINED" && t("typeReferralJoined")}
{notif.type === "REFERRAL_RANK_UP" && t("typeReferralRankUp")}
{notif.type === "STORY_MENTION" && t("typeStoryMention")}
{notif.type === "STORY_COMMENT" && t("typeStoryComment")}
{notif.type === "STORY_REACTION" && t("typeStoryReaction")}
{notif.type === "VACCINE_DUE" && notif.vaccine?.nextDueDate &&
t("typeVaccineDue", {
name: notif.vaccine.name,
@@ -0,0 +1,243 @@
"use client";
import { useLayoutEffect, useRef, useState, type CSSProperties } from "react";
import {
OVERLAY_SIZES,
STORY_BACKGROUNDS,
containRect,
contrastTextColor,
overlayCenter,
type Rect,
type StoryOverlay,
} from "@/lib/story-overlays";
import { STICKER_OUTLINE, STORY_STICKERS, type StickerPart } from "@/lib/story-stickers";
type MentionedPet = { id: string; name: string };
/**
* Web-Anzeige des Story-Editors (erstellt wird nur in der App). Legt Text,
* Markierungen, GIFs und Sticker auf die Medienfläche — dieselbe Geometrie und
* dieselben Größenregeln wie mobile/src/components/story-editor/, damit alles an
* derselben Stelle sitzt. Bei Text-Storys zeichnet die Ebene auch den Farbverlauf.
*/
export function StoryOverlayLayer({
overlays,
mediaSize,
mentionedPets,
background,
showOverlays,
onMentionClick,
}: {
overlays: readonly StoryOverlay[];
mediaSize: { width: number; height: number };
mentionedPets: readonly MentionedPet[];
/** Nur Text-Storys: Farbverlauf-Schlüssel */
background?: string | null;
/** Notschalter: aus → nur der Farbverlauf, keine Overlays */
showOverlays: boolean;
onMentionClick?: (petId: string) => void;
}) {
const containerRef = useRef<HTMLDivElement>(null);
const [box, setBox] = useState({ width: 0, height: 0 });
useLayoutEffect(() => {
const el = containerRef.current;
if (!el) return;
const update = () => setBox({ width: el.clientWidth, height: el.clientHeight });
update();
const observer = new ResizeObserver(update);
observer.observe(el);
return () => observer.disconnect();
}, []);
const rect = containRect(box.width, box.height, mediaSize.width, mediaSize.height);
return (
<div ref={containerRef} className="pointer-events-none absolute inset-0" aria-hidden={!showOverlays}>
<StoryOverlayStatic
overlays={overlays}
rect={rect}
mentionedPets={mentionedPets}
background={background}
showOverlays={showOverlays}
onMentionClick={onMentionClick}
/>
</div>
);
}
/** Reine Darstellung auf einer bekannten Medienfläche — ohne Messen (auch für Vorschau/Tests). */
export function StoryOverlayStatic({
overlays,
rect,
mentionedPets,
background,
showOverlays,
onMentionClick,
}: {
overlays: readonly StoryOverlay[];
rect: Rect;
mentionedPets: readonly MentionedPet[];
background?: string | null;
showOverlays: boolean;
onMentionClick?: (petId: string) => void;
}) {
if (rect.width <= 0) return null;
const names = new Map(mentionedPets.map((p) => [p.id, p.name]));
const gradient = background ? STORY_BACKGROUNDS[background] ?? STORY_BACKGROUNDS.sunset : null;
return (
<>
{gradient && (
<div
className="absolute"
style={{
left: rect.x,
top: rect.y,
width: rect.width,
height: rect.height,
background: `linear-gradient(160deg, ${gradient[0]}, ${gradient[1]})`,
}}
/>
)}
{showOverlays &&
overlays.map((overlay, i) => (
<Positioned key={i} overlay={overlay} rect={rect}>
{overlay.kind === "mention" ? (
<button
type="button"
className="pointer-events-auto"
onClick={(e) => {
e.stopPropagation();
onMentionClick?.(overlay.petId);
}}
>
<MentionChip name={names.get(overlay.petId) ?? "…"} baseWidth={rect.width} />
</button>
) : (
<OverlayContent overlay={overlay} baseWidth={rect.width} />
)}
</Positioned>
))}
</>
);
}
function Positioned({ overlay, rect, children }: { overlay: StoryOverlay; rect: Rect; children: React.ReactNode }) {
const { left, top } = overlayCenter(rect, overlay);
return (
<div
className="absolute"
style={{
left,
top,
transform: `translate(-50%, -50%) rotate(${overlay.rotation}deg) scale(${overlay.scale})`,
}}
>
{children}
</div>
);
}
function OverlayContent({ overlay, baseWidth }: { overlay: StoryOverlay; baseWidth: number }) {
switch (overlay.kind) {
case "text":
return <TextContent overlay={overlay} baseWidth={baseWidth} />;
case "gif": {
const width = OVERLAY_SIZES.gifWidth * baseWidth;
return (
// eslint-disable-next-line @next/next/no-img-element -- animiertes GIF von GIPHY, kein next/image
<img
src={overlay.url}
alt="GIF"
width={width}
height={(width * overlay.height) / overlay.width}
style={{ width, height: (width * overlay.height) / overlay.width, borderRadius: baseWidth * 0.02, objectFit: "cover" }}
/>
);
}
case "sticker":
return <Sticker stickerId={overlay.stickerId} size={OVERLAY_SIZES.sticker * baseWidth} />;
case "mention":
return null;
}
}
/** Gleiche Regeln wie textAppearance() in der App (OverlayContent.tsx). */
function textAppearance(overlay: Extract<StoryOverlay, { kind: "text" }>): { color: string; background?: string } {
switch (overlay.style) {
case "box":
return { color: contrastTextColor(overlay.color), background: overlay.color };
case "soft":
return { color: overlay.color, background: overlay.color === "#171717" ? "rgba(255,255,255,0.85)" : "rgba(0,0,0,0.55)" };
default:
return { color: overlay.color };
}
}
function TextContent({ overlay, baseWidth }: { overlay: Extract<StoryOverlay, { kind: "text" }>; baseWidth: number }) {
const fontSize = OVERLAY_SIZES.textFont * baseWidth;
const { color, background } = textAppearance(overlay);
const style: CSSProperties = {
maxWidth: OVERLAY_SIZES.textMaxWidth * baseWidth,
width: "max-content",
fontSize,
lineHeight: 1.2,
color,
fontWeight: overlay.font === "bold" ? 700 : 400,
textAlign: "center",
whiteSpace: "pre-wrap",
overflowWrap: "break-word",
background,
borderRadius: fontSize * 0.3,
padding: background ? `${fontSize * 0.18}px ${fontSize * 0.4}px` : 0,
textShadow: background ? undefined : "0 1px 6px rgba(0,0,0,0.45)",
};
return <div style={style}>{overlay.text}</div>;
}
function MentionChip({ name, baseWidth }: { name: string; baseWidth: number }) {
const fontSize = OVERLAY_SIZES.mentionFont * baseWidth;
return (
<span
className="block whitespace-nowrap font-bold hover:underline"
style={{
fontSize,
lineHeight: 1.25,
color: "#f97316",
background: "#ffffff",
borderRadius: fontSize,
padding: `${fontSize * 0.25}px ${fontSize * 0.6}px`,
}}
>
@{name}
</span>
);
}
function Sticker({ stickerId, size }: { stickerId: string; size: number }) {
const sticker = STORY_STICKERS.find((s) => s.id === stickerId);
if (!sticker) return null;
return (
<svg width={size} height={size} viewBox="-6 -6 112 112" role="img" aria-label={sticker.label}>
{sticker.parts.map((part, i) => (
<Shape key={`o${i}`} part={part} fill={STICKER_OUTLINE.color} stroke={STICKER_OUTLINE.color} strokeWidth={STICKER_OUTLINE.width} />
))}
{sticker.parts.map((part, i) => (
<Shape key={`f${i}`} part={part} fill={part.fill} />
))}
</svg>
);
}
function Shape({ part, fill, stroke, strokeWidth }: { part: StickerPart; fill: string; stroke?: string; strokeWidth?: number }) {
const strokeProps = stroke ? { stroke, strokeWidth, strokeLinejoin: "round" as const } : {};
switch (part.type) {
case "circle":
return <circle cx={part.cx} cy={part.cy} r={part.r} fill={fill} {...strokeProps} />;
case "rect":
return <rect x={part.x} y={part.y} width={part.width} height={part.height} rx={part.rx} fill={fill} {...strokeProps} />;
case "path":
return <path d={part.d} fill={fill} {...strokeProps} />;
}
}
+27
View File
@@ -2,6 +2,7 @@
import { useState, useEffect, useCallback, useRef } from "react";
import { createPortal } from "react-dom";
import { useRouter } from "next/navigation";
import dynamic from "next/dynamic";
import { X, Eye, Volume2, VolumeX, Loader2, MessageCircle, Trash2, PawPrint, Clock } from "lucide-react";
import { toast } from "sonner";
@@ -34,6 +35,8 @@ import { AiDisclosureBadge } from "@/components/content/AiDisclosureBadge";
import { StoryPawButton } from "@/components/stories/StoryPawButton";
import { StoryCommentsOverlay } from "@/components/stories/StoryCommentsOverlay";
import { RankRing } from "@/components/referrals/RankRing";
import { StoryOverlayLayer } from "@/components/stories/StoryOverlayLayer";
import { storyMediaSize } from "@/lib/story-overlays";
// Same lazy-load rationale as VideoCard.tsx — keep the HLS.js player runtime
// out of the main bundle, only load it when a video story actually renders.
@@ -102,6 +105,11 @@ export function StoryViewer({
const currentStory = stories[currentIndex];
const isOwnPet = activePetId === petId;
const isVideo = currentStory?.mediaType === "VIDEO";
const isText = currentStory?.mediaType === "TEXT";
const router = useRouter();
// Story-Editor-Notschalter (Admin): aus → Overlays ausblenden.
const { data: featureFlags } = useQuery({ ...trpc.stories.featureFlags.queryOptions(), staleTime: 60_000 });
const showOverlays = featureFlags?.storyEditor ?? false;
const musicUrl = currentStory?.musicTrack ? getMusicUrl(currentStory.musicTrack.storageKey) : null;
// For a VIDEO story, the overlay track only plays if musicMuteOriginal was
// chosen at creation time (see StoryForm.tsx) — otherwise the video keeps
@@ -265,6 +273,21 @@ export function StoryViewer({
if (!currentStory) return null;
const mediaUrl = currentStory.storageKey ? getMediaUrl(currentStory.storageKey) : null;
// Fläche, auf die sich Story-Editor-Overlays beziehen (null = alte Story ohne Maße → keine Overlays).
const overlayMediaSize = storyMediaSize(currentStory);
const overlayLayer = overlayMediaSize ? (
<StoryOverlayLayer
overlays={currentStory.overlays}
mediaSize={overlayMediaSize}
mentionedPets={currentStory.mentionedPets}
background={isText ? currentStory.background : null}
showOverlays={showOverlays}
onMentionClick={(mentionedPetId) => {
handleClose();
router.push(`/pets/${mentionedPetId}`);
}}
/>
) : null;
return (
<>
@@ -369,12 +392,15 @@ export function StoryViewer({
)}
</button>
)}
{videoStatus === "READY" && overlayLayer}
<AiDisclosureBadge
value={currentStory.aiDisclosure}
className="top-auto left-auto bottom-3 right-16 h-10"
/>
</div>
</div>
) : isText ? (
<div className="relative w-full h-full">{overlayLayer}</div>
) : (
mediaUrl && (
<div className="relative w-full h-full">
@@ -385,6 +411,7 @@ export function StoryViewer({
className="block w-full h-full object-contain"
wrapperClassName="relative block w-full h-full"
/>
{overlayLayer}
<AiDisclosureBadge
value={currentStory.aiDisclosure}
className="top-auto left-auto bottom-3 right-3 h-10"