Skip to content

Add missing skeleton loading to product page of Boilerplate (#9773)#9774

Merged
msynk merged 9 commits intobitfoundation:developfrom
msynk:9773-templates-boilerplate-productpage-skeleton-loading
Feb 1, 2025
Merged

Add missing skeleton loading to product page of Boilerplate (#9773)#9774
msynk merged 9 commits intobitfoundation:developfrom
msynk:9773-templates-boilerplate-productpage-skeleton-loading

Conversation

@msynk
Copy link
Member

@msynk msynk commented Feb 1, 2025

closes #9773

Summary by CodeRabbit

  • New Features

    • Upgraded loading screens on both the home and product pages with a more structured look that mirrors actual product displays.
    • Introduced a brief, controlled pause during product loading for a smoother, more natural data presentation.
  • Style

    • Optimized the layout of product sections for a full-width, polished interface.
  • Bug Fixes

    • Improved backend cache management to ensure product updates and deletions are accurately reflected.

@msynk msynk requested a review from yasmoradi February 1, 2025 09:26
@coderabbitai
Copy link

coderabbitai bot commented Feb 1, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This pull request updates the loading indicators on both the HomePage and ProductPage. The previous simple loading animations have been replaced with structured skeletons using components like BitCard, BitStack, and BitShimmer. In addition, a 2000ms delay has been introduced in the HomePage's LoadProducts method under conditional compilation, and a new CSS rule sets the width of a product container to 100%. The ProductController’s cache purge parameters have also been updated to reference a revised API endpoint pattern.

Changes

File(s) Change Summary
src/.../HomePage.razor & src/.../ProductPage.razor Updated loading UI: replaced BitEllipsisLoading with a BitCard-based skeleton (using BitStack, ProductImage, BitShimmer), removed redundant tags.
src/.../HomePage.razor.cs Inserted a 2000ms asynchronous delay in the LoadProducts method with conditional compilation for the "Sales" module.
src/.../HomePage.razor.scss Added a CSS rule to set the .products-inf-scr element’s width to 100%.
src/.../ProductController.cs Modified the PurgeCache method calls to use the updated endpoint pattern "api/ProductView/Get/{dto.Id}" in both Update and Delete methods.

Sequence Diagram(s)

sequenceDiagram
    participant HP as HomePage
    participant LP as LoadProducts
    participant PVC as ProductViewController
    HP->>LP: Call LoadProducts(request)
    LP->>LP: Wait 2000ms delay
    LP->>PVC: Request products
    PVC-->>LP: Return product list
    LP-->>HP: Return products for display
Loading
sequenceDiagram
    participant PP as ProductPage
    participant PD as ProductData
    PP->>PP: Evaluate isLoadingProduct flag
    Note right of PP: Show skeleton loader (BitCard, BitShimmer, etc.)
    PP->>PD: Request product details
    PD-->>PP: Return product details
    PP->>PP: Render product information
Loading

Assessment against linked issues

Objective Addressed Explanation
Loading component must use a skeleton (#9773)

Poem

I'm a rabbit hopping through lines of code,
Where skeleton loaders make a lighter load.
BitCards and shimmers sparkle in view,
A 2-second pause—refreshing and new.
With cache and CSS tuned just right, I celebrate changes day and night! 🐰


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 2

🧹 Nitpick comments (4)
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Products/ProductController.cs (2)

81-81: Consider using Url.Action for URL generation.

While the URL pattern is now more explicit, using string literals for URLs can be fragile. As suggested in the comment, consider using Url.Action to generate the URLs, which would make the code more maintainable and less prone to errors when routes change.

Example implementation:

-        await responseCacheService.PurgeCache("/", $"product/{dto.Id}", $"api/ProductView/Get/{dto.Id}" /*You can also use Url.Action to build urls.*/);
+        await responseCacheService.PurgeCache(
+            Url.Action("Index", "Home")!, 
+            Url.Action("Index", "Product", new { id = dto.Id })!,
+            Url.Action("Get", "ProductView", new { id = dto.Id })!
+        );

97-97: Extract duplicated URL patterns to constants or helper method.

The same URL patterns are duplicated between Update and Delete methods. Consider extracting these to constants or a helper method to follow the DRY principle.

Example implementation:

+    private const string HOME_URL = "/";
+    private const string PRODUCT_URL_FORMAT = "product/{0}";
+    private const string PRODUCT_VIEW_URL_FORMAT = "api/ProductView/Get/{0}";
+
+    private (string homeUrl, string productUrl, string productViewUrl) GetCacheUrls(Guid productId)
+    {
+        return (
+            HOME_URL,
+            string.Format(PRODUCT_URL_FORMAT, productId),
+            string.Format(PRODUCT_VIEW_URL_FORMAT, productId)
+        );
+    }

     public async Task<ProductDto> Update(ProductDto dto, CancellationToken cancellationToken)
     {
         // ... existing code ...
-        await responseCacheService.PurgeCache("/", $"product/{dto.Id}", $"api/ProductView/Get/{dto.Id}");
+        var (homeUrl, productUrl, productViewUrl) = GetCacheUrls(dto.Id);
+        await responseCacheService.PurgeCache(homeUrl, productUrl, productViewUrl);
         // ... existing code ...
     }

     public async Task Delete(Guid id, string concurrencyStamp, CancellationToken cancellationToken)
     {
         // ... existing code ...
-        await responseCacheService.PurgeCache("/", $"product/{id}", $"api/ProductView/Get/{id}");
+        var (homeUrl, productUrl, productViewUrl) = GetCacheUrls(id);
+        await responseCacheService.PurgeCache(homeUrl, productUrl, productViewUrl);
         // ... existing code ...
     }
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/ProductPage.razor (2)

20-31: LGTM! Consider semantic height values for shimmers.

The skeleton loading implementation effectively mirrors the actual content layout. However, consider using more semantic height values for shimmers that match the actual content heights (e.g., use typography-based heights like h2, h4, h6 instead of fixed rem values).

-                        <BitShimmer Height="6rem" Width="100%" />
-                        <BitShimmer Height="1rem" Width="100%" />
-                        <BitShimmer Height="1rem" Width="100%" />
-                        <BitShimmer Height="1rem" Width="100%" />
-                        <BitShimmer Height="3rem" Width="100%" />
+                        <BitShimmer Height="var(--bit-typography-h2-line-height)" Width="100%" />
+                        <BitShimmer Height="var(--bit-typography-body2-line-height)" Width="100%" />
+                        <BitShimmer Height="var(--bit-typography-h6-line-height)" Width="100%" />
+                        <BitShimmer Height="var(--bit-typography-body2-line-height)" Width="100%" />
+                        <BitShimmer Height="var(--bit-typography-h4-line-height)" Width="100%" />

35-45: Enhance about section skeleton to better match content.

The about section skeleton could better reflect the actual content structure which includes headings, paragraphs, and a list.

             <BitCard FullWidth>
                 <BitStack AutoHeight Grows>
-                    <BitShimmer Height="1rem" Width="100%" />
-                    <BitShimmer Height="1rem" Width="100%" />
-                    <BitShimmer Height="1rem" Width="100%" />
-                    <BitShimmer Height="1rem" Width="100%" />
-                    <BitShimmer Height="1rem" Width="100%" />
+                    <BitStack Gap="1rem">
+                        <BitStack>
+                            <BitShimmer Height="var(--bit-typography-body1-line-height)" Width="90%" />
+                            <BitShimmer Height="var(--bit-typography-body1-line-height)" Width="85%" />
+                        </BitStack>
+                        <BitStack>
+                            <BitShimmer Height="var(--bit-typography-body1-line-height)" Width="88%" />
+                            <BitShimmer Height="var(--bit-typography-body1-line-height)" Width="92%" />
+                        </BitStack>
+                        <BitStack Gap="0.5rem">
+                            <BitShimmer Height="var(--bit-typography-body1-line-height)" Width="20%" />
+                            <BitShimmer Height="var(--bit-typography-body1-line-height)" Width="15%" />
+                            <BitShimmer Height="var(--bit-typography-body1-line-height)" Width="18%" />
+                        </BitStack>
+                    </BitStack>
                 </BitStack>
             </BitCard>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d63b52c and 9f4db2c.

📒 Files selected for processing (5)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/HomePage.razor (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/HomePage.razor.cs (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/HomePage.razor.scss (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/ProductPage.razor (2 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Products/ProductController.cs (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build and test
🔇 Additional comments (2)
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/HomePage.razor (1)

76-84: Well-implemented skeleton loading template!

The skeleton loading implementation effectively mirrors the actual product item layout, providing a smooth and consistent user experience during loading. The use of BitShimmer components with appropriate heights creates a natural placeholder effect.

src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/HomePage.razor.scss (1)

39-39: LGTM!

Setting width to 100% ensures the infinite scroll container properly fills its parent, maintaining consistent layout for both skeleton loading and actual content.

@msynk msynk merged commit c749a1e into bitfoundation:develop Feb 1, 2025
2 checks passed
@msynk msynk deleted the 9773-templates-boilerplate-productpage-skeleton-loading branch February 1, 2025 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The loading component used in the product page of the Boilerplate project template needs to be a skeleton

2 participants