fix(web): dedup bboxCropStyle util + apply to explore cards #660

Merged
chris merged 2 commits from fix/discovery-thumbnail-crop into main 2026-07-20 21:25:37 +02:00
Owner

Summary

Extract duplicated bboxCropStyle function into shared `$lib/utils/discoveryThumbnail.ts` utility module. Apply bbox-based thumbnail cropping to explore page discovery cards.

Changes

  • NEW `apps/web/src/lib/utils/discoveryThumbnail.ts` — shared `bboxCropStyle()` with clamped center + zoom cap
  • EDIT `DiscoveryDomainInstances.svelte` — import shared util, remove local `bboxCropStyle`
  • EDIT `DiscoveryInstanceDetail.svelte` — import shared util, remove local `bboxCropStyle`
  • EDIT `explore/+page.svelte` — extend `ExploreInstance` type with `representativeBbox`, use raw `` with `bboxCropStyle` when bbox available, fall back to `ProgressiveImage`

Algorithm note

Spec file `docs/superpowers/specs/2026-07-20-discovery-thumbnail-crop-design.md` line 89 has `Math.min` (typo — wrong direction, would never zoom in). Used `Math.max` per Team Chef. Spec file needs separate correction (follow-up).

Verification

  • svelte-check: 0 errors (20 pre-existing warnings)
  • No local `bboxCropStyle` definitions remain in components/
  • 3 imports from shared util (2 components + explore page)
  • Diff is only claimed files (4 files)
## Summary Extract duplicated `bboxCropStyle` function into shared \`\$lib/utils/discoveryThumbnail.ts\` utility module. Apply bbox-based thumbnail cropping to explore page discovery cards. ## Changes - **NEW** \`apps/web/src/lib/utils/discoveryThumbnail.ts\` — shared \`bboxCropStyle()\` with clamped center + zoom cap - **EDIT** \`DiscoveryDomainInstances.svelte\` — import shared util, remove local \`bboxCropStyle\` - **EDIT** \`DiscoveryInstanceDetail.svelte\` — import shared util, remove local \`bboxCropStyle\` - **EDIT** \`explore/+page.svelte\` — extend \`ExploreInstance\` type with \`representativeBbox\`, use raw \`<img>\` with \`bboxCropStyle\` when bbox available, fall back to \`ProgressiveImage\` ## Algorithm note Spec file \`docs/superpowers/specs/2026-07-20-discovery-thumbnail-crop-design.md\` line 89 has \`Math.min\` (typo — wrong direction, would never zoom in). Used \`Math.max\` per Team Chef. Spec file needs separate correction (follow-up). ## Verification - [x] svelte-check: 0 errors (20 pre-existing warnings) - [x] No local \`bboxCropStyle\` definitions remain in components/ - [x] 3 imports from shared util (2 components + explore page) - [x] Diff is only claimed files (4 files)
fix(web): dedup bboxCropStyle util + apply to explore cards
Some checks failed
Build and Deploy / Detect changed services and test scopes (push) Successful in 3s
Build and Deploy / Smoke API and media worker (push) Has been skipped
Build and Deploy / Smoke web (push) Has been skipped
Build and Deploy / Smoke ML worker (push) Has been skipped
Build and Deploy / Build plants worker image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Build converter worker image (push) Has been skipped
Build and Deploy / Build API image (push) Has been skipped
Build and Deploy / Build media worker image (push) Has been skipped
Build and Deploy / Build ML worker image (push) Has been skipped
Build and Deploy / Build web image (push) Has been skipped
Build and Deploy / Deploy API (push) Has been skipped
Build and Deploy / Deploy web (push) Has been skipped
Build and Deploy / Deploy media worker (push) Has been skipped
Build and Deploy / Deploy ML worker (push) Has been skipped
Build and Deploy / Deploy plants worker (push) Has been skipped
Build and Deploy / Deploy people worker (push) Has been skipped
Build and Deploy / Deploy converter worker (push) Has been skipped
Build and Deploy / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Failing after 3m34s
a4489b98dd
Extract bboxCropStyle into shared $lib/utils/discoveryThumbnail.ts.
Uses Math.max for zoom (not Math.min as in spec — see note below).
Applies bbox-based thumbnail crop to explore page cards.

Note: spec file docs/superpowers/specs/2026-07-20-discovery-thumbnail-crop-design.md
line 89 has Math.min (typo, wrong direction — would never zoom in).
Used Math.max per Team Chef. Spec file needs separate correction.
chore: bump version to v1.21.15
All checks were successful
Build and Deploy / Detect changed services and test scopes (push) Successful in 3s
Build and Deploy / Smoke API and media worker (push) Has been skipped
Build and Deploy / Smoke web (push) Has been skipped
Build and Deploy / Smoke ML worker (push) Has been skipped
Build and Deploy / Build plants worker image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Build converter worker image (push) Has been skipped
Build and Deploy / Build API image (push) Has been skipped
Build and Deploy / Build media worker image (push) Has been skipped
Build and Deploy / Build ML worker image (push) Has been skipped
Build and Deploy / Build web image (push) Has been skipped
Build and Deploy / Deploy API (push) Has been skipped
Build and Deploy / Deploy web (push) Has been skipped
Build and Deploy / Deploy media worker (push) Has been skipped
Build and Deploy / Deploy ML worker (push) Has been skipped
Build and Deploy / Deploy plants worker (push) Has been skipped
Build and Deploy / Deploy people worker (push) Has been skipped
Build and Deploy / Deploy converter worker (push) Has been skipped
Build and Deploy / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Successful in 2m38s
6a4a63440c
chris merged commit caf8219a07 into main 2026-07-20 21:25:37 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
chris/memories!660
No description provided.