Skip to content

Conversation

@gocanto
Copy link
Contributor

@gocanto gocanto commented Oct 6, 2025

Summary

  • replace the article list cover image markup with CoverImageLoader so it shares the skeleton animation pattern
  • keep the error fallback icon within the loader while simplifying the component state management

Testing

  • npm test (fails: vitest command not available in the execution environment)
  • make format

https://chatgpt.com/codex/tasks/task_e_68e33556a09083338d00bd5fbca871cb

Summary by CodeRabbit

  • New Features
    • Cover images now use a shared loader with lazy loading, low fetch priority, consistent skeletons, and a built-in placeholder when no image is provided.
  • Refactor
    • Consolidated image handling into the shared loader and simplified article list rendering to reduce layout shifts and streamline loading states.
  • Tests
    • Added/updated tests to verify placeholder rendering and loader behavior when image sources are missing.

@coderabbitai
Copy link

coderabbitai bot commented Oct 6, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Replaced inline image handling in article items with a CoverImageLoader component, moved import paths, adjusted ArticlesListPartial rendering structure, updated CoverImageLoader to provide a built-in placeholder when src is missing, and updated tests to reflect the new component and placeholder behavior.

Changes

Cohort / File(s) Summary of Changes
Article item thumbnail
src/partials/ArticleItemPartial.vue
Replaced inline <img> and local load/error state with CoverImageLoader usage; pass src, width, height, fetchpriority="low", loading="lazy"; removed manual handlers and state; provide skeleton slot for error SVG.
Cover image component
src/partials/CoverImageLoader.vue
Use resolvedSrc (fallback to built-in SVG data URL) as :src; render <img> when !isError; treat missing src as loaded (not error); removed hasSource computed; added placeholderCoverImage constant.
Articles list rendering
src/partials/ArticlesListPartial.vue
Reworked conditional rendering into a min-height wrapper: show loading skeleton while isLoading, else render items via ArticleItemPartial when present, otherwise show "No articles found."
Import path adjustments
src/pages/AboutPage.vue, src/pages/PostPage.vue
Updated imports to reference @/partials/CoverImageLoader.vue (was @/components/...).
Tests updated
tests/components/CoverImageLoader.test.ts, tests/partials/ArticleItemPartial.test.ts
Import paths updated to @/partials/...; added test asserting built-in placeholder when no src; ArticleItemPartial tests now assert CoverImageLoader props and placeholder behavior for undefined cover_image_url.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant R as RouterLink / Card
  participant A as ArticleItemPartial
  participant C as CoverImageLoader
  participant N as Network/Image

  U->>R: open / view article card
  R->>A: mount ArticleItemPartial
  A->>C: render CoverImageLoader(src = item.cover_image_url ?? '')
  C->>N: request image (loading="lazy", fetchpriority="low")
  alt image loads successfully
    N-->>C: 200 OK
    C-->>A: render `<img>` (opacity visible)
  else image fails or src empty
    N-->>C: error / no src
    C-->>A: render skeleton slot → shows placeholder SVG
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

codex

Poem

A rabbit nudged a tiny view,
Replaced the img with something new.
If pixels come, the cover beams,
If not, a little SVG redeems.
Hop—lazy load, low-priority too. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly and accurately captures the main change by describing the alignment of article cover image loading with the skeleton animation pattern, matching the PR’s objective of replacing image handling with the CoverImageLoader component. It avoids extraneous details and clearly informs reviewers of the key enhancement. The phrasing is concise and specific, reflecting the central update without noise.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch gocanto/use-skeleton-animation-for-images-loading-2025-10-06-afvw9c

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 27f2dd4 and 4e3056c.

📒 Files selected for processing (7)
  • src/pages/AboutPage.vue (1 hunks)
  • src/pages/PostPage.vue (1 hunks)
  • src/partials/ArticleItemPartial.vue (2 hunks)
  • src/partials/ArticlesListPartial.vue (1 hunks)
  • src/partials/CoverImageLoader.vue (4 hunks)
  • tests/components/CoverImageLoader.test.ts (2 hunks)
  • tests/partials/ArticleItemPartial.test.ts (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/pages/PostPage.vue
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/partials/ArticleItemPartial.vue
🔇 Additional comments (12)
src/partials/ArticlesListPartial.vue (1)

24-31: LGTM!

The nested structure with a min-height container improves the UX by maintaining consistent height during loading transitions. The conditional rendering logic correctly handles the three states: loading skeletons, article items, and empty state.

tests/components/CoverImageLoader.test.ts (2)

3-3: LGTM!

Import path correctly updated to reflect the component's new location in the partials directory.


48-64: LGTM!

The new test properly validates the placeholder behavior when no source is provided. It correctly verifies that:

  • The skeleton animation is not shown
  • The placeholder image renders with a data URL
  • The image is immediately visible (opacity-100)
  • The error state container is not rendered
tests/partials/ArticleItemPartial.test.ts (3)

5-5: LGTM!

Import added to support the updated tests that verify CoverImageLoader usage.


45-49: LGTM!

Test correctly updated to verify CoverImageLoader component existence and prop passing instead of directly checking the img element.


51-69: LGTM!

The new test properly validates placeholder behavior when cover_image_url is undefined. It verifies that:

  • CoverImageLoader receives an empty string for src
  • The placeholder SVG is rendered
  • The component handles the missing URL gracefully

Note: The type assertion undefined as unknown as string on line 56 is necessary to test the edge case but should not occur in production code.

src/partials/CoverImageLoader.vue (5)

4-4: LGTM!

Simplified condition correctly reflects that the image should render whenever there's no error, regardless of whether a source was provided (since resolvedSrc now always provides a valid source).


7-7: LGTM!

Binding to resolvedSrc ensures the component always has a valid image source, either the provided URL or the built-in placeholder.


33-34: LGTM!

The placeholder SVG provides a clean fallback when no source is provided. The data URL approach avoids an additional network request.


62-68: LGTM!

The resolvedSrc computed property elegantly handles the placeholder fallback, ensuring a valid image source is always available. This simplifies the component's state management.


96-96: LGTM!

Setting imageStatus to 'loaded' when no source is provided is the correct design decision. This treats the placeholder as immediately available content rather than an error state, which aligns with the intended UX (no skeleton animation for the placeholder).

src/pages/AboutPage.vue (1)

95-95: All CoverImageLoader imports use the new partials path
No remaining references to @/components/CoverImageLoader.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello @gocanto, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request aims to standardize the loading and display of article cover images by refactoring the ArticleItemPartial.vue component. It achieves this by integrating a dedicated CoverImageLoader component, which encapsulates the logic for handling various image loading states, including skeleton animations and error fallbacks. This change results in a more modular and maintainable approach to image presentation, ensuring a consistent user experience across the application.

Highlights

  • Component Refactoring: The article list cover image markup in ArticleItemPartial.vue has been replaced with the CoverImageLoader component. This change centralizes image loading, skeleton animation, and error handling logic.
  • State Management Simplification: The local state management for image loading (including imageStatus ref, handleImageLoad, handleImageError, and related computed properties and watchers) has been removed from ArticleItemPartial.vue, simplifying its internal logic.
  • Consistent UI/UX: By utilizing the CoverImageLoader, the display of article cover images now consistently applies skeleton animations during loading and provides a standardized error fallback icon.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gocanto gocanto marked this pull request as draft October 6, 2025 03:59
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the article list item to use a CoverImageLoader component for handling cover image display, loading states, and error fallbacks. This is a positive change that simplifies the ArticleItemPartial component by encapsulating image loading logic. My main feedback is a critical one regarding testing: the unit tests for ArticleItemPartial need to be updated to reflect the structural changes from this refactoring, as they are likely broken.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/partials/ArticleItemPartial.vue (1)

9-10: Consider responsive dimension handling.

The width and height are hardcoded to 112 pixels, optimized for the sm:w-28 breakpoint, but the mobile view uses w-20 (80px). While the browser will scale appropriately, this means mobile devices may download a larger image than needed.

If optimizing for mobile performance is a priority, consider using responsive image techniques or adjusting the dimensions to match the mobile size (80px), as mobile users are more likely to be on slower connections.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d5389d7 and 27f2dd4.

📒 Files selected for processing (1)
  • src/partials/ArticleItemPartial.vue (2 hunks)
🔇 Additional comments (3)
src/partials/ArticleItemPartial.vue (3)

4-30: Nice refactoring to use CoverImageLoader!

The refactoring successfully:

  • Centralizes image loading logic in a reusable component
  • Maintains the skeleton animation pattern
  • Preserves error state handling with the SVG fallback
  • Applies appropriate lazy loading with low fetch priority for list items

The skeleton slot pattern correctly shows the error SVG only when isError is true, allowing the component to manage its default loading skeleton.


66-66: LGTM!

The import statement correctly follows the project's path alias conventions.


7-7: Empty-string src fallback is handled correctly. CoverImageLoader defaults src to '', sets imageStatus to error on falsy values, and passes isError to the skeleton slot—no changes required.

@gocanto gocanto added testing and removed codex labels Oct 6, 2025
@gocanto gocanto marked this pull request as ready for review October 6, 2025 04:37
@gocanto gocanto merged commit 205ba74 into main Oct 6, 2025
5 checks passed
@gocanto gocanto deleted the gocanto/use-skeleton-animation-for-images-loading-2025-10-06-afvw9c branch October 6, 2025 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants