From 0efe83047c8cf93a661fd09a74f822ec73bf114a Mon Sep 17 00:00:00 2001 From: Kentai Radiquum Date: Sun, 23 Feb 2025 01:43:10 +0500 Subject: [PATCH] fix/generator: visible overlay when images weren't loaded --- generate/build.tsx | 2 +- generate/static/css/tailwind.css | 53 +++++------------------------ generate/static/js/initGalleries.js | 8 +++++ generate/templates/Base.tsx | 2 +- generate/templates/YearPhotos.tsx | 22 ++++++------ 5 files changed, 30 insertions(+), 57 deletions(-) diff --git a/generate/build.tsx b/generate/build.tsx index 30dda74..6bd26c9 100644 --- a/generate/build.tsx +++ b/generate/build.tsx @@ -123,7 +123,7 @@ Object.keys(items).forEach((year) => { const html = renderToString( -
+
{Object.keys(items).sort().reverse().map((year) => ( = 48rem) { - justify-content: space-between; - } - } .md\:gap-2 { @media (width >= 48rem) { gap: calc(var(--spacing) * 2); @@ -824,30 +807,12 @@ grid-template-columns: repeat(5, minmax(0, 1fr)); } } - .lg\:text-base { - @media (width >= 64rem) { - font-size: var(--text-base); - line-height: var(--tw-leading, var(--text-base--line-height)); - } - } - .lg\:text-lg { - @media (width >= 64rem) { - font-size: var(--text-lg); - line-height: var(--tw-leading, var(--text-lg--line-height)); - } - } .lg\:text-sm { @media (width >= 64rem) { font-size: var(--text-sm); line-height: var(--tw-leading, var(--text-sm--line-height)); } } - .lg\:text-xl { - @media (width >= 64rem) { - font-size: var(--text-xl); - line-height: var(--tw-leading, var(--text-xl--line-height)); - } - } .xl\:grid-cols-7 { @media (width >= 80rem) { grid-template-columns: repeat(7, minmax(0, 1fr)); diff --git a/generate/static/js/initGalleries.js b/generate/static/js/initGalleries.js index 5fbaf86..9c4a1f4 100644 --- a/generate/static/js/initGalleries.js +++ b/generate/static/js/initGalleries.js @@ -31,6 +31,14 @@ Images.forEach((item) => { availableTags.push(imTags[i]); } } + if (item.querySelector("img").height > 0) { + item.querySelector("[data-overlay]").classList.remove("invisible"); + } else { + item.querySelector("img").addEventListener("load", () => { + item.querySelector("[data-overlay]").classList.remove("invisible"); + this.removeEventListener("load", this); + }); + } } }); diff --git a/generate/templates/Base.tsx b/generate/templates/Base.tsx index b2bb243..df3344c 100644 --- a/generate/templates/Base.tsx +++ b/generate/templates/Base.tsx @@ -65,7 +65,7 @@ export default function Base({ children, isDev }: BaseProps) { - +
{children}