-
Notifications
You must be signed in to change notification settings - Fork 0
fix: card image aspect ratios #897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Warning: Component files have been updated but no migrations have been added. See https://github.com/yext/visual-editor/blob/main/packages/visual-editor/src/components/migrations/README.md for more information. |
WalkthroughEvent and Insight section slot migrations now compute aspectRatio by dividing width by height, rounding the result to two decimal places, and falling back to 16/9 when dimensions are missing. Product section slot sets the ImageSlot aspectRatio to 1.78. ProductCard image styling was changed from a fixed small-screen height ( Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (22)
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/visual-editor/src/components/migrations/0025_event_section_slots.ts (1)
71-78: LGTM! Identical aspect ratio calculation pattern as Insight section.The dynamic calculation with two-decimal precision correctly addresses the precision mismatch and adapts to actual image dimensions.
To reduce duplication, consider extracting the aspect ratio calculation into a shared helper function:
// In a shared utilities file export const calculateAspectRatio = (width?: number, height?: number): number => { return width && height ? parseFloat((width / height).toFixed(2)) : 16 / 9; };Then use it in both Event and Insight migrations:
styles: { width: event.image?.width || 640, - aspectRatio: - event.image?.width && event.image?.height - ? parseFloat( - ( - event.image.width / event.image.height - ).toFixed(2) - ) - : 16 / 9, + aspectRatio: calculateAspectRatio( + event.image?.width, + event.image?.height + ), },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
packages/visual-editor/src/components/migrations/0025_event_section_slots.ts(1 hunks)packages/visual-editor/src/components/migrations/0031_product_section_slots.ts(1 hunks)packages/visual-editor/src/components/migrations/0032_insight_section_slots.ts(1 hunks)packages/visual-editor/src/components/pageSections/ProductSection/ProductCard.tsx(1 hunks)
🔇 Additional comments (2)
packages/visual-editor/src/components/migrations/0032_insight_section_slots.ts (1)
55-62: LGTM! Dynamic aspect ratio calculation with proper precision.The two-decimal rounding via
parseFloat(toFixed(2))correctly addresses the precision mismatch issue (1.777... → 1.78) while adapting to actual image dimensions. The fallback to16/9when dimensions are unavailable is appropriate.packages/visual-editor/src/components/pageSections/ProductSection/ProductCard.tsx (1)
323-323: LGTM! Enables aspect ratio prop to control image height.Replacing the Tailwind height classes (
h-auto sm:h-[200px]) with inlinestyle={{ height: "auto" }}removes the responsive height override, allowing theaspectRatiostyle prop (set in the ImageSlot configuration) to properly control the image dimensions.
Three of the migrations were failing to apply the aspect ratio because the dropdown select value is 1.78 but the division was returning 1.77777778
Also fixes that Product Cards weren't responding to the aspect ratio style prop