Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat(web): expand video comments in CommentMiniPlayer
Richie McIlroy2cda0a6ae33b
diff --git a/apps/web/app/s/[videoId]/_components/media-comment/VideoCommentCard.tsx b/apps/web/app/s/[videoId]/_components/media-comment/VideoCommentCard.tsxindex 1ac0db8ca..fefb93b10 100644--- a/apps/web/app/s/[videoId]/_components/media-comment/VideoCommentCard.tsx+++ b/apps/web/app/s/[videoId]/_components/media-comment/VideoCommentCard.tsx@@ -3,6 +3,7 @@import { motion } from "motion/react";import { useCallback, useEffect, useRef, useState } from "react";import { commentMediaUrl } from "@/lib/comment-media";+import { CommentMiniPlayer } from "./CommentMiniPlayer";import { formatMediaDuration } from "./format-media-duration";import type { MediaComment } from "./media-comment-types";import {@@ -43,6 +44,7 @@ export const VideoCommentCard = ({className,}: VideoCommentCardProps) => {const [playing, setPlaying] = useState(false);+ const [expanded, setExpanded] = useState(false);const videoRef = useRef<HTMLVideoElement | null>(null);const progressRef = useRef<HTMLDivElement | null>(null);const labelRef = useRef<HTMLSpanElement | null>(null);@@ -97,6 +99,15 @@ export const VideoCommentCard = ({if (el) releasePlayback(el, { resumeMain: true });}, [collapse]);+ // Hand off to the dialog: fold the inline element away but leave its claim+ // in place — releasing here would clear the registry's owed-resume flag.+ // The mini player's own claim takes the slot over when its video mounts,+ // and its close is what hands the main video back.+ const expand = useCallback(() => {+ collapse();+ setExpanded(true);+ }, [collapse]);+// The <video> mounts only after the play click, so claiming happens via ref// callback rather than an effect racing autoPlay.const attachVideo = useCallback(@@ -149,24 +160,47 @@ export const VideoCommentCard = ({onClick={togglePause}className="object-cover size-full cursor-pointer"/>- <button- type="button"- onClick={close}- aria-label="Close video comment"- className="absolute top-1.5 right-1.5 grid size-6 place-items-center rounded-full bg-black/45 text-white backdrop-blur-md"- >- <svg- width="10"- height="10"- viewBox="0 0 10 10"- stroke="currentColor"- strokeWidth="1.5"- strokeLinecap="round"- aria-hidden="true"+ <div className="absolute top-1.5 right-1.5 flex items-center gap-1">+ <button+ type="button"+ onClick={expand}+ aria-label="Open in mini player"+ title="Open in mini player"+ className="grid size-6 place-items-center rounded-full bg-black/45 text-white backdrop-blur-md transition-colors hover:bg-black/65"+ >+ <svg+ width="10"+ height="10"+ viewBox="0 0 10 10"+ stroke="currentColor"+ strokeWidth="1.5"+ strokeLinecap="round"+ strokeLinejoin="round"+ fill="none"+ aria-hidden="true"+ >+ <path d="M6 1h3v3M9 1 5.6 4.4M4 9H1V6M1 9l3.4-3.4" />+ </svg>+ </button>+ <button+ type="button"+ onClick={close}+ aria-label="Close video comment"+ className="grid size-6 place-items-center rounded-full bg-black/45 text-white backdrop-blur-md transition-colors hover:bg-black/65">- <path d="M1 1l8 8M9 1l-8 8" />- </svg>- </button>+ <svg+ width="10"+ height="10"+ viewBox="0 0 10 10"+ stroke="currentColor"+ strokeWidth="1.5"+ strokeLinecap="round"+ aria-hidden="true"+ >+ <path d="M1 1l8 8M9 1l-8 8" />+ </svg>+ </button>+ </div><spanref={labelRef}className="absolute bottom-1.5 right-1.5 rounded bg-black/60 px-1.5 py-0.5 text-[10px] tabular-nums text-white"@@ -188,17 +222,11 @@ export const VideoCommentCard = ({whileTap={{ scale: 0.985 }}className="relative block size-full">- {posterUrl ? (- // biome-ignore lint/performance/noImgElement: signed 302 URL, next/image adds nothing- <img- src={posterUrl}- alt=""- className="object-cover size-full"- loading="lazy"- />- ) : localUrl ? (- // Optimistic cards have no uploaded thumbnail yet; the blob's own- // first frame stands in via preload="metadata".+ {localUrl ? (+ // The author's own blob wins while it's registered (through the+ // upload AND the settle): its first frame via preload="metadata"+ // is already painted, and switching to the uploaded poster+ // mid-settle would flash the card for no visual gain.<videosrc={localUrl}preload="metadata"@@ -206,6 +234,14 @@ export const VideoCommentCard = ({playsInlineclassName="object-cover size-full pointer-events-none"/>+ ) : posterUrl ? (+ // biome-ignore lint/performance/noImgElement: signed 302 URL, next/image adds nothing+ <img+ src={posterUrl}+ alt=""+ className="object-cover size-full"+ loading="lazy"+ />) : (<div className="grid size-full place-items-center bg-gradient-to-br from-gray-3 to-gray-5 text-gray-8"><FilmGlyph />@@ -230,6 +266,15 @@ export const VideoCommentCard = ({</span></motion.button>)}+++ {expanded && src && (+ <CommentMiniPlayer+ comment={comment}+ src={src}+ onClose={() => setExpanded(false)}+ />+ )}</div>);};