From a836d24d9f9e7c59368aa37fce2391f003fdf8cd Mon Sep 17 00:00:00 2001 From: Kentai Radiquum Date: Fri, 31 Jan 2025 22:56:09 +0500 Subject: [PATCH] Create a PlaceHolder component --- src/static/populate_index.js | 4 ++-- src/templates/Components/PlaceHolder.tsx | 18 ++++++++++++++++++ src/templates/index.tsx | 21 +++++---------------- 3 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 src/templates/Components/PlaceHolder.tsx diff --git a/src/static/populate_index.js b/src/static/populate_index.js index 599c768..b6d2ffe 100644 --- a/src/static/populate_index.js +++ b/src/static/populate_index.js @@ -25,7 +25,7 @@ async function FetchData() { // let videos = await get("/data/videos.json"); const Images = document.querySelectorAll( - '[data-type="index__placeholder__image"]' + '[data-type="placeholder__image"]' ); const VisibleImages = []; Images.forEach((placeholder) => { @@ -37,7 +37,7 @@ async function FetchData() { randomElements(images, VisibleImages.length).forEach((image, idx) => { const src = `${config.endpoint}/${config.bucket}/${config.prefix}/${image.src}`; const loader = document.getElementById( - `index__placeholder__image-${idx + 1}-loader` + `placeholder__image-${idx + 1}-loader` ); const blurImg = document.createElement("img"); const Img = document.createElement("img"); diff --git a/src/templates/Components/PlaceHolder.tsx b/src/templates/Components/PlaceHolder.tsx new file mode 100644 index 0000000..59603aa --- /dev/null +++ b/src/templates/Components/PlaceHolder.tsx @@ -0,0 +1,18 @@ +export default function Placeholder(props: { + idx: string | number; + isMobileHidden?: boolean; +}) { + return ( + +
+
+ ); +} diff --git a/src/templates/index.tsx b/src/templates/index.tsx index 18256cc..6fc82ac 100644 --- a/src/templates/index.tsx +++ b/src/templates/index.tsx @@ -1,4 +1,6 @@ import AllLink from "./Components/AllLink"; +import Placeholder from "./Components/PlaceHolder"; + export default function IndexPage() { return (
@@ -7,23 +9,10 @@ export default function IndexPage() { id="index_images" className="mt-4 flex overflow-x-auto sm:overflow-x-hidden sm:grid sm:grid-cols-[repeat(auto-fill,minmax(25%,1fr))] xl:grid-cols-[repeat(auto-fill,minmax(20%,1fr))] sm:items-center sm:justify-center gap-4" > - {[1, 2, 3, 4, 5, 6, 7].map((num, idx) => { - return ( - = 5 ? "hidden xl:block" : "" - }`} - > -
-
- ); + {[1, 2, 3, 4, 5, 6, 7].map((idx) => { + return 5} />; })} - +
);