Skip to content

Feat: Add reusable shimmer component and loading state in task list#35

Merged
yesyash merged 22 commits intoRealDevSquad:developfrom
shubhdevelop:UI-shimmerComponent
Mar 27, 2025
Merged

Feat: Add reusable shimmer component and loading state in task list#35
yesyash merged 22 commits intoRealDevSquad:developfrom
shubhdevelop:UI-shimmerComponent

Conversation

@shubhdevelop
Copy link
Contributor

@shubhdevelop shubhdevelop commented Mar 15, 2025

Date: 15th March 2025

Developer Name: Shubham Raj


Issue Ticket Number

Description

This Added component works as the as an loading state, while the data is being fetched, based on the loading state wee conditionally renders either the shimmer Skeleton animation component or the child component if the fetching/loading is finished

Usage

{
 isFetchingTaskData ?  <Shimmer className={"bg-blue"} /> : <TaskList tasks={inProgressTasks} setActiveTask={handleTaskSelect} />
}

Documentation Updated?

  • Yes
  • No

Under Feature Flag

  • Yes
  • No

Database Changes

  • Yes
  • No

Breaking Changes

  • Yes
  • No

Development Tested?

  • Yes
  • No

Screencast

Screencast 1
Screencast.from.2025-03-23.04-04-04.mp4

Test Coverage

Unit Test

test coverage
image

Additional Notes

Have added fake delay in the useEffect to simulate delay in the data fetching

@coderabbitai
Copy link

coderabbitai bot commented Mar 15, 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.

Summary by CodeRabbit

  • New Features

    • Added a visual loading indicator that displays a smooth shimmer effect while tasks load.
    • Introduced a delay simulation during task fetching, providing users with a more refined display transition.
  • Style

    • Enhanced global styling with new shimmer animations that offer customizable dimensions for a polished look.

Walkthrough

The pull request introduces a new ShimmerSkeleton component along with its corresponding tests to manage loading states. A new CSS animation and class are added to create the shimmer effect, and the Tasks page is updated to wrap task lists in the ShimmerSkeleton component. The tests validate both loading and loaded scenarios as well as custom and default styling dimensions. All changes are additive, with no modifications to existing public interfaces.

Changes

File(s) Change Summary
__tests__/unit/ShimmerSkeleton.test.tsx
components/SimmerSkeleton.tsx
Added a new ShimmerSkeleton component and unit tests covering loading state, loaded state, and custom/default dimensional properties using React Testing Library and Vitest.
app/globals.css Introduced a new @keyframes shimmer animation and an .animate-shimmer CSS class to implement the shimmer effect.
app/tasks/page.tsx Updated the Tasks page by adding an isFetchingTaskData state and wrapping task lists with the ShimmerSkeleton component to simulate a loading state with a 2000ms delay.

Sequence Diagram(s)

sequenceDiagram
  participant U as User
  participant TP as Tasks Page
  participant SS as ShimmerSkeleton
  participant TL as TaskList

  U->>TP: Navigate to Tasks Page
  TP->>TP: Initialize state (isFetchingTaskData = true)
  TP->>SS: Render ShimmerSkeleton (loading = true)
  SS->>SS: Check loading prop (true)
  SS-->>U: Display shimmer effect
  TP->>TP: Simulate delay (2000ms via setTimeout)
  TP->>TP: Update state (isFetchingTaskData = false)
  TP->>SS: Render ShimmerSkeleton (loading = false)
  SS->>TL: Render TaskList with task data
  TL-->>U: Display tasks
Loading

Poem

I'm a bunny hopping through the code,
Shimmering lights on the loading road.
Tests and styles now in the mix,
With a shimmer here and a smooth fix.
🐇 Hooray for clear paths and new tricks!


🪧 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.
  • @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: 11

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3dc0fbf and 4a7bdd4.

📒 Files selected for processing (4)
  • __tests__/unit/ShimmerSkeleton.test.tsx (1 hunks)
  • app/globals.css (1 hunks)
  • app/tasks/page.tsx (1 hunks)
  • components/SimmerSkeleton.tsx (1 hunks)
🔇 Additional comments (7)
components/SimmerSkeleton.tsx (1)

4-10: Well-defined props interface

The props interface is clearly defined with appropriate types and documentation. Good job including optional properties for customizing the component dimensions.

app/tasks/page.tsx (3)

11-14: Good approach for tracking loading state

The code correctly adds a state variable to track data fetching status and efficiently filters tasks by status.


32-34: Good implementation of ShimmerSkeleton for Todo section

The ShimmerSkeleton component is correctly integrated with the TaskList to show loading state.


39-41: Good implementation of ShimmerSkeleton for In Progress section

The ShimmerSkeleton component is correctly integrated with the TaskList to show loading state.

__tests__/unit/ShimmerSkeleton.test.tsx (3)

14-28: Well-written test for the loading state

This test correctly verifies that the shimmer is shown and children are hidden during loading.


45-62: Good test for custom dimensions

This test effectively verifies that custom dimension props are correctly applied to the component.


64-81: Comprehensive test for default dimensions

This test effectively verifies the default behavior when custom dimensions are not provided.

@shubhdevelop shubhdevelop changed the title Added shimmer component Added reusable shimmer component and loading state in task list Mar 16, 2025
@AnujChhikara
Copy link
Contributor

Can you please attach the test coverage report in the screenshot section?

@shubhdevelop
Copy link
Contributor Author

Can you please attach the test coverage report in the screenshot section?

all the test cases are passing, test by test report is not there in the coverage report, i have added the screenshot add test cases I have added

@Achintya-Chatterjee Achintya-Chatterjee changed the title Added reusable shimmer component and loading state in task list Feat: Adde reusable shimmer component and loading state in task list Mar 20, 2025
@Achintya-Chatterjee Achintya-Chatterjee changed the title Feat: Adde reusable shimmer component and loading state in task list Feat: Add reusable shimmer component and loading state in task list Mar 20, 2025
- componet now accepts className and style as an props
- more clean up
- changed test, and added 1 more test case for testing
	the case where style object is present
-  Added test for the utility
- added twMerge and clsx utility pacakages
@yesyash yesyash requested a review from MayankBansal12 March 27, 2025 06:00
@yesyash yesyash merged commit 4216eff into RealDevSquad:develop Mar 27, 2025
2 checks passed
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.

[UI] add simmer effect while loading the /tasks page

5 participants