Skip to content

feat(web): utilize image dimensions for CLS prevention (#141)#144

Merged
thxforall merged 4 commits into
devfrom
feat/141-cls-prevention
Apr 9, 2026
Merged

feat(web): utilize image dimensions for CLS prevention (#141)#144
thxforall merged 4 commits into
devfrom
feat/141-cls-prevention

Conversation

@thxforall
Copy link
Copy Markdown
Contributor

@thxforall thxforall commented Apr 9, 2026

Summary

DB의 image_width/image_height 값을 활용하여 CLS(Cumulative Layout Shift) 개선.

PostImage 핵심 변경 (Reddit-style)

  • fill 모드 → width/height props 기반으로 전환
  • 컨테이너가 이미지 비율에 맞게 자연스럽게 높이 결정, maxHeight로 제한
  • 이미지가 maxHeight에 안 걸리면 → 블러 없이 딱 맞음
  • 이미지가 maxHeight에 걸리면 → object-contain + 블러 배경
  • 블러 배경 400 에러 수정 (/_next/image 이중 프록시 → image-proxy 직접 사용)

컴포넌트별 변경

  • PostImage: imageWidth/imageHeight props 추가, Reddit-style 레이아웃
  • FeedCard: DB dimension 기반 동적 aspect ratio
  • SavedGrid: useImageDimensions 훅 활용
  • MasonryGridItem: image_width/image_height fallback 체인
  • RelatedLooksSection: style.aspectRatio (fallback 유지)
  • GallerySection: 동일 패턴
  • useImages: PostGridItem에 dimension 필드 추가

모든 컴포넌트에 null dimension fallback 유지 (기존 레이아웃 호환).

Test plan

  • tsc --noEmit 통과
  • 메인 페이지 Masonry 그리드 확인
  • 피드 카드 이미지 비율 확인
  • 블러 배경 정상 로딩 확인

🤖 Generated with Claude Code

- Add imageWidth/imageHeight to PostGridItem and FeedCardItem types
- Map image_width/image_height from Supabase and REST API in useImages.ts
- FeedClient passes dimensions through to FeedCardItem
- FeedCard sets container aspect ratio from DB dimensions (fallback: none)
- SavedGrid extracts SavedGridItemCard using useImageDimensions hook for aspect ratio
- RelatedLooksSection/GallerySection accept width/height on image types, use style.aspectRatio with fallback height classes
- MasonryGridItem derives aspectRatio from image_width/image_height when aspectRatio field absent
- GridItemData type extended with image_width/image_height optional fields

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
decoded-app Error Error Apr 9, 2026 11:39am

…aspectRatio

PostImage container now uses DB dimensions to set aspectRatio,
eliminating letterbox margins and matching the image's natural ratio.
Works in both dynamic (blur bg + object-contain) and fallback modes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Switch from fill mode to width/height props so container height
flows naturally from image ratio, capped by maxHeight.
- Image fits → no blur visible (container matches image exactly)
- Image exceeds maxHeight → object-contain + blur fills gaps
- Browser pre-reserves space from width/height → zero CLS

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
getBlurSrc was wrapping image-proxy URL inside /_next/image optimizer
which rejected local API URLs with query params. Simplified to use
image-proxy directly for external URLs — CSS background-image doesn't
need Next.js optimization and the browser caches the full image anyway.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@thxforall thxforall merged commit 184790f into dev Apr 9, 2026
3 of 4 checks passed
@thxforall thxforall deleted the feat/141-cls-prevention branch April 9, 2026 11:48
@github-project-automation github-project-automation Bot moved this from Todo to Done in decoded-monorepo Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant