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
+4 -3
View File
@@ -491,6 +491,9 @@ importers:
'@xmorse/deployment-utils':
specifier: ^0.7.2
version: 0.7.2(@types/node@25.0.3)(jiti@2.6.1)(lightningcss@1.31.1)(tsx@4.20.6)(yaml@2.6.0)
sharp:
specifier: ^0.34.5
version: 0.34.5
tailwindcss:
specifier: ^4.2.0
version: 4.2.0
@@ -7856,8 +7859,7 @@ snapshots:
'@iarna/toml@2.2.5': {}
'@img/colour@1.0.0':
optional: true
'@img/colour@1.0.0': {}
'@img/sharp-darwin-arm64@0.34.5':
optionalDependencies:
@@ -12869,7 +12871,6 @@ snapshots:
'@img/sharp-win32-arm64': 0.34.5
'@img/sharp-win32-ia32': 0.34.5
'@img/sharp-win32-x64': 0.34.5
optional: true
shebang-command@2.0.0:
dependencies: