From 75d60a05409b5bc135756289eec5ce44a3c6eed7 Mon Sep 17 00:00:00 2001 From: harbassan Date: Sat, 31 Aug 2024 16:17:30 +1200 Subject: [PATCH] chore(frontend/Thumbnail): replace old element --- frontend/src/components/ListContainer.jsx | 7 +- frontend/src/components/Thumbnail.jsx | 100 ------------------ .../components/__tests__/Thumbnail.test.js | 14 --- .../__snapshots__/Thumbnail.test.js.snap | 74 ------------- .../{ThumbImage.jsx => Thumbnail.jsx} | 4 +- .../SceneNavigator/SceneNavigator.jsx | 4 +- .../containers/pages/Dashboard/SceneNode.jsx | 10 +- 7 files changed, 9 insertions(+), 204 deletions(-) delete mode 100644 frontend/src/components/Thumbnail.jsx delete mode 100644 frontend/src/components/__tests__/Thumbnail.test.js delete mode 100644 frontend/src/components/__tests__/__snapshots__/Thumbnail.test.js.snap rename frontend/src/containers/pages/AuthoringTool/Components/{ThumbImage.jsx => Thumbnail.jsx} (98%) diff --git a/frontend/src/components/ListContainer.jsx b/frontend/src/components/ListContainer.jsx index 17747906..c51d4c0d 100644 --- a/frontend/src/components/ListContainer.jsx +++ b/frontend/src/components/ListContainer.jsx @@ -4,9 +4,8 @@ import { Box } from "@material-ui/core"; import ImageList from "@material-ui/core/ImageList"; import ImageListItem from "@material-ui/core/ImageListItem"; -import ThumbImage from "containers/pages/AuthoringTool/Components/ThumbImage"; +import Thumbnail from "containers/pages/AuthoringTool/Components/Thumbnail"; import DashedCard from "./DashedCard"; -import Thumbnail from "./Thumbnail"; import styles from "../styling/ListContainer.module.scss"; import useStyles from "./component.styles"; @@ -130,9 +129,9 @@ export default function ListContainer({ }} > {sceneSelectionPage ? ( - + ) : ( - )} diff --git a/frontend/src/components/Thumbnail.jsx b/frontend/src/components/Thumbnail.jsx deleted file mode 100644 index 379fb0b5..00000000 --- a/frontend/src/components/Thumbnail.jsx +++ /dev/null @@ -1,100 +0,0 @@ -import { useState } from "react"; -import Skeleton from "react-loading-skeleton"; - -/** - * Component used for thumbnails. - * - * @component - * @example - * const url = "https://canvas.ac.nz/" - * const interactive = false - * function onLoad() { - * console.log("Loading...") - * } - * return ( - * - * ) - */ -function Thumbnail({ - url = "https://canvas.ac.nz/", - iframeWidth = 1920, - iframeHeight = 1080, - width = 266, - height = 150, - interactive = false, - style: customStyle, - onLoad, -}) { - const [loading, setLoading] = useState(true); - - const xscale = width / iframeWidth; - const yscale = height / iframeHeight; - const iframe = { - transform: `scaleX(${xscale}) scaleY(${yscale})`, - transformOrigin: "0 0", - width: `${iframeWidth}px`, - height: `${iframeHeight}px`, - border: "0px", - }; - - const iframeShade = { - position: "absolute", - width: "100%", - height: `${height}px`, - maxWidth: `${width}px`, - zIndex: "10", - }; - - const iframeWrapper = { - maxWidth: `${width}px`, - maxHeight: `${height}px`, - backgroundColor: "white", - filter: "drop-shadow(1px 1px 2px grey)", - }; - - const outerWrapper = { - display: "flex", - alignItems: "center", - justifyContent: "center", - width: "100%", - height: "100%", - }; - - /** Function which executes while the thumbnail is loading. */ - const combinedOnLoad = () => { - if (onLoad) { - onLoad(); - } - setLoading(false); - }; - - return ( -
-
- {!interactive &&
} - {loading && ( - - )} -