-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
42 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
zbook_frontend/src/components/parsers/VideoWithFallBack.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"use client"; | ||
import React, { useState } from "react"; | ||
import { FaVideo, FaVideoSlash } from "react-icons/fa"; | ||
|
||
const VideoWithFallBack = ({ src, alt }: { src: string; alt: string }) => { | ||
const [imgLoaded, setImgLoaded] = useState(false); | ||
const [imgError, setImgError] = useState(false); | ||
|
||
return ( | ||
<> | ||
{!imgLoaded && !imgError && ( | ||
<FaVideo className="w-full my-[1.25em] h-96 rounded-md py-40 bg-gray-200 dark:bg-gray-700/75 animate-pulse text-slate-500 dark:text-slate-400" /> | ||
)} | ||
{imgError && ( | ||
<FaVideoSlash className="w-full my-[1.25em] h-96 rounded-md py-40 bg-gray-200 dark:bg-gray-700/75 text-slate-500 dark:text-slate-400" /> | ||
)} | ||
<iframe | ||
className="w-full embed-video my-[1.25em] rounded-md" | ||
src={src} | ||
style={{ display: imgLoaded && !imgError ? "block" : "none" }} | ||
onLoad={() => setImgLoaded(true)} | ||
onError={() => setImgError(true)} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
export default VideoWithFallBack; |