website: add pixelated image placeholders with fade-in transition

Build-time script generates tiny 32px-wide versions of all images in
public/ using sharp. At runtime, PixelatedImage component renders these
with CSS image-rendering: pixelated (nearest-neighbor / point sampling)
for a crisp mosaic effect, then fades in the real image on load.

- Auto-discovers images in public/, skips placeholder- prefixed files
- Mtime check skips regeneration when placeholder is newer than source
- Callback ref handles cached images where onLoad fires before mount
- Explicit z-index prevents placeholder from covering the real image
- Runs automatically as part of pnpm build in website package
This commit is contained in:
Tommy D. Rossi
2026-02-21 15:22:39 +01:00
parent 00baca9c2b
commit 3b3959f5ab
9 changed files with 179 additions and 10 deletions
+3 -1
View File
@@ -3,7 +3,8 @@
"private": true,
"type": "module",
"scripts": {
"build": "react-router build",
"placeholders": "tsx scripts/generate-placeholders.ts",
"build": "tsx scripts/generate-placeholders.ts && react-router build",
"dev": "react-router dev --port 8044",
"typecheck": "react-router typegen && tsc"
},
@@ -39,6 +40,7 @@
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^5.1.2",
"@xmorse/deployment-utils": "^0.7.2",
"sharp": "^0.34.5",
"tailwindcss": "^4.2.0",
"typescript": "^5.9.3",
"vite": "^7.3.0",