"use client"; import type { CSSProperties } from "react"; import { useReducedMotion } from "@/app/hooks/useReducedMotion"; import { getProjectVideo, getShowcaseConfig } from "@/lib/project-showcase"; import { ProjectVideo } from "../ProjectVideo"; import { BrowserFrame, displayUrl } from "./BrowserFrame"; import { useShowcaseCard } from "./ShowcaseProvider"; import { useNearViewport, useViewportDevice } from "./useShowcaseMedia"; /** * Capa do card com vídeo: o vídeo dentro de uma moldura de navegador, com brilho da cor do site quando é o * card que toca, e o botão que amplia (a tela inteira é o botão). A versão do aparelho (celular abaixo de * 768 px) só é escolhida no navegador; no servidor e antes de a capa chegar a ~1 tela da janela, nem o pôster * é pedido (a moldura já reserva o espaço). */ export function ProjectMedia({ project, }: { project: { id: string; title: string; demoUrl?: string | null; }; }) { const { frameRef, active, open, userPaused, toggleAutoplay } = useShowcaseCard(project.id); const reducedMotion = useReducedMotion(); const device = useViewportDevice(); const near = useNearViewport(frameRef); const video = device ? getProjectVideo(project.id, device) : undefined; const config = getShowcaseConfig(project.id); if (!getProjectVideo(project.id) || !config) return null; return (
{video && ( )} {!reducedMotion && ( )}
); }