diff --git a/storefront/components/sections/hero/index.tsx b/storefront/components/sections/hero/index.tsx index d3bf01a..050561e 100644 --- a/storefront/components/sections/hero/index.tsx +++ b/storefront/components/sections/hero/index.tsx @@ -1,21 +1,15 @@ -import MuxVideo from "@/components/shared/mux-video"; import {SanityImage} from "@/components/shared/sanity-image"; +import Video from "@/components/shared/video"; import {stegaClean} from "@sanity/client/stega"; -import React from "react"; import type {ModularPageSection} from "../types"; import LargeHero from "./large-hero"; import SimpleHero from "./simple-hero"; -interface VideoData { - playbackId?: string; - resolution?: string; -} - export default function Hero(props: ModularPageSection<"section.hero">) { const mediaType = stegaClean(props.mediaType); - const video = stegaClean(props.video?.asset) as unknown as VideoData; + const video = props.video; const largeImage = stegaClean(props.largeImage); return (
) { {mediaType === "image" && } {mediaType === "video" && video && ( - +
+
)} {mediaType === "largeImage" && largeImage && ( diff --git a/storefront/components/shared/mux-video.tsx b/storefront/components/shared/mux-video.tsx deleted file mode 100644 index 5ecfb91..0000000 --- a/storefront/components/shared/mux-video.tsx +++ /dev/null @@ -1,113 +0,0 @@ -"use client"; - -import useInView from "@/hooks/use-in-view"; -import Image, {getImageProps} from "next/image"; -import React, {useEffect} from "react"; -import {preload} from "react-dom"; - -export type MuxVideoProps = { - loading?: "eager" | "lazy"; - video?: { - playbackId?: string; - resolution?: string; - }; -} & Omit; - -export default function MuxVideo({ - loading, - video, - ...videoProps -}: MuxVideoProps) { - const {playbackId, resolution} = video ?? {}; - - if (!playbackId || !resolution) { - return null; - } - - const mp4Url = `https://stream.mux.com/${playbackId}/${ - resolution === "SD" ? "medium" : "high" - }.mp4`; - - const webmUrl = `https://stream.mux.com/${playbackId}/${ - resolution === "SD" ? "medium" : "high" - }.webm`; - - const { - props: {src: poster}, - } = getImageProps({ - alt: "", - fill: true, - src: `https://image.mux.com/${playbackId}/thumbnail.webp?fit_mode=smartcrop&time=0`, - }); - - if (loading === "eager") { - preload(poster, { - as: "image", - fetchPriority: "high", - }); - - return ( -