Skip to content

[Feat]: Add Skeleton Loading State for project list #3725

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

Merged
merged 2 commits into from
Apr 4, 2025

Conversation

Innocent-Akim
Copy link
Contributor

@Innocent-Akim Innocent-Akim commented Apr 3, 2025

  • Create ProjectListSkeleton component for loading state
  • Replace spinner with skeleton in project list table
  • Show table structure with placeholder content during loading
  • Add animated loading effects for better UX

Description

Please include a summary of the changes and the related issues.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented on my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

Previous screenshots

Screenshot 2025-04-03 at 13 37 17

Please add here videos or images of the previous status

Current screenshots

Screenshot 2025-04-03 at 13 33 53

Please add here videos or images of the current (new) status

Summary by CodeRabbit

  • New Features

    • Introduced a new skeleton loading display to replace the previous spinner, streamlining the loading experience.
    • Added breadcrumb navigation for improved user navigation.
    • Integrated a back button in the header for easier navigation to the previous page.
  • Style

    • Enhanced table presentation with an updated border for a cleaner, more defined appearance.

- Create ProjectListSkeleton component for loading state
- Replace spinner with skeleton in project list table
- Show table structure with placeholder content during loading
- Add animated loading effects for better UX
@Innocent-Akim Innocent-Akim self-assigned this Apr 3, 2025
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here: https://app.greptile.com/review/github.

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Copy link
Contributor

coderabbitai bot commented Apr 3, 2025

Walkthrough

This pull request replaces the existing spinner-based loading indicator in the ProjectsTable component with a skeleton loading component. The SpinnerLoader has been removed from the data table, and a new ProjectListSkeleton component is introduced to provide visual placeholders while data loads. Additionally, the styling for the table container has been adjusted to include a border by updating its CSS classes.

Changes

File(s) Change Summary
apps/web/app/[locale]/projects/components/project-views/list-view/data-table.tsx Removed SpinnerLoader markup and replaced it with the ProjectListSkeleton component; updated container classes from rounded-md to rounded-md border.
apps/web/app/[locale]/projects/components/project-views/list-view/list-skeleton.tsx Added new ProjectListSkeleton component rendering a table skeleton with headers and rows utilizing nested arrays for multiple loading placeholders.
apps/web/app/[locale]/projects/components/page-component.tsx Enhanced PageComponent with new imports, state management, and navigation features, including breadcrumb navigation and layout control improvements.

Sequence Diagram(s)

sequenceDiagram
    participant UI as User Interface
    participant DT as DataTable Component
    participant PLS as ProjectListSkeleton Component
    participant SK as Skeleton Elements

    UI->>DT: Request project list
    DT->>PLS: Trigger loading state rendering
    PLS->>SK: Render skeleton headers and rows
    UI->>DT: Data loaded (replacing skeleton)
Loading

Possibly related PRs

Suggested labels

feature, UI/UX, Improvement, Ever Teams

Suggested reviewers

  • evereq

Poem

In a realm of code so bright,
I hop along with pure delight.
No spinners spinning in my view,
Skeletons now shine fresh and new.
With borders neat and changes to boot,
I cheer this code—oh, how it’s astute!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/web/app/[locale]/projects/components/page-component.tsx

Oops! Something went wrong! :(

ESLint: 8.46.0

ESLint couldn't find the config "next/core-web-vitals" to extend from. Please check that the name of the config is correct.

The config "next/core-web-vitals" was referenced from the config file in "/apps/web/.eslintrc.json".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.


📜 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 6e315e1 and 0e7cfa9.

📒 Files selected for processing (1)
  • apps/web/app/[locale]/projects/components/page-component.tsx (7 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: deploy
🔇 Additional comments (8)
apps/web/app/[locale]/projects/components/page-component.tsx (8)

7-18: LGTM: Organized imports for new icon components

The imports are well-organized and include the necessary ArrowLeftIcon component for the back button functionality.


20-20: LGTM: Added required UI components

The added imports for Breadcrumb and Container components are necessary for the new UI elements and layout structure.


39-42: LGTM: Added necessary navigation and state management hooks

The imports for Next.js routing hooks and Jotai state management are appropriate for implementing the navigation features and responsive layout.


58-62: LGTM: Proper initialization of navigation and layout state

Good use of hooks to set up router, layout width state, and locale parameters for internationalization support.


95-96: LGTM: Simple and effective back navigation

The handleBack function correctly uses router navigation to return to the previous page.


220-226: LGTM: Well-structured header with navigation elements

Good implementation of the header with:

  • Container that respects the fullWidth state
  • Back button with appropriate styling and icon
  • Breadcrumb navigation showing the current path

269-272: LGTM: Consistent layout with Container component

Good use of the Container component for the main content area, maintaining consistency with the header implementation and respecting the fullWidth state.


86-93:

❓ Verification inconclusive

Verify the JSON.parse usage for breadcrumb title

The use of JSON.parse(t('pages.home.BREADCRUMB')) for the home breadcrumb title seems unusual. This suggests the translation string might be stored as a JSON string, which is not a common practice.

Consider checking if this is intentional or if it should be a direct string:

-{ title: JSON.parse(t('pages.home.BREADCRUMB')), href: '/' },
+{ title: t('pages.home.BREADCRUMB'), href: '/' },

🏁 Script executed:

#!/bin/bash
# Check how the breadcrumb translation is used elsewhere in the codebase
rg -A 2 -B 2 "pages\.home\.BREADCRUMB" --type ts --type tsx

Length of output: 89


Below is a revised review comment that reflects the need for additional manual verification due to the previous command’s file type error. Please verify the output of the revised search command manually to ensure the translation string’s handling is intentional.


Action: Confirm the intended usage of JSON.parse for the home breadcrumb translation

  • Location: apps/web/app/[locale]/projects/components/page-component.tsx (Lines 86–93)

  • Observation: The current code uses JSON.parse(t('pages.home.BREADCRUMB')) which is unusual. Automated search for "pages.home.BREADCRUMB" did not yield results because the file type tsx wasn’t recognized. This raises the question: Is the translation string stored as a JSON string intentionally, or should it be a plain string?

  • Diff Suggestion (if the JSON parsing is not needed):

    -{ title: JSON.parse(t('pages.home.BREADCRUMB')), href: '/' },
    +{ title: t('pages.home.BREADCRUMB'), href: '/' },
  • Next Steps: Please execute the following revised shell script to search for usages of pages.home.BREADCRUMB properly (note the addition for TSX file types) and manually verify its intended usage:

    #!/bin/bash
    # Re-run the search for "pages.home.BREADCRUMB" in both TS and TSX files
    rg --type-add 'tsx:*.tsx' -A 2 -B 2 "pages\.home\.BREADCRUMB" --type ts --type tsx

Once you’ve confirmed whether the JSON.parse is intentional based on the translation's format elsewhere in the code, update the code accordingly.


Action Required: Verify JSON.parse Usage for Breadcrumb Translation

  • Location: apps/web/app/[locale]/projects/components/page-component.tsx (Lines 86–93)

  • Observation: The current code uses JSON.parse(t('pages.home.BREADCRUMB')), which is unusual because translation strings are typically plain strings. It’s unclear whether the JSON format is intentional or a mistake.

  • Next Steps:
    Please execute the following refined shell script to search for usages of "pages.home.BREADCRUMB" in both TS and TSX files (with the TSX file type properly added) to determine if the translation is stored as a JSON string elsewhere in the codebase:

    #!/bin/bash
    # Re-run search for "pages.home.BREADCRUMB" in TS and TSX files with proper TSX type addition
    rg --type-add 'tsx:*.tsx' -A 3 -B 3 "pages\.home\.BREADCRUMB" --type ts --type tsx
  • Diff Suggestion (if JSON parsing is not required):

    - { title: JSON.parse(t('pages.home.BREADCRUMB')), href: '/' },
    + { title: t('pages.home.BREADCRUMB'), href: '/' },

Please verify the output manually to ensure that the use of JSON.parse is intentional. Adjust the code accordingly based on your findings.


Action: Confirm the JSON.parse usage in the home breadcrumb translation

  • Location: apps/web/app/[locale]/projects/components/page-component.tsx (Lines 86–93)
  • Observation: The code currently uses JSON.parse(t('pages.home.BREADCRUMB')), which is unusual since translation strings are typically plain strings. There is a possibility that the translation may be stored in JSON format on purpose, or this may be an error.
  • Diff Suggestion (if JSON parsing is not required):
    - { title: JSON.parse(t('pages.home.BREADCRUMB')), href: '/' },
    + { title: t('pages.home.BREADCRUMB'), href: '/' },
  • Next Steps:
    To decide the correct approach, please manually verify how the translation for pages.home.BREADCRUMB is used in the codebase. You can use a command like the one below (or a similar file search) to inspect its usage in TSX files:
    rg -g "*.tsx" -A 3 -B 3 "pages\.home\.BREADCRUMB"
    Confirm whether the translation string is indeed stored as a JSON string. Update the code accordingly based on your findings.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 plan to trigger planning for file edits and PR creation.
  • @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
Contributor

@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 (2)
apps/web/app/[locale]/projects/components/project-views/list-view/list-skeleton.tsx (2)

4-82: Consider accessibility improvements

While the skeleton implementation is visually effective, it could benefit from accessibility enhancements.

Consider adding ARIA attributes to improve accessibility for screen reader users:

-export function ProjectListSkeleton() {
+export function ProjectListSkeleton() {
 	return (
-		<div className="w-full">
+		<div className="w-full" role="status" aria-busy="true" aria-label="Loading projects">
 			<div className="rounded-md border">

Also consider memoizing the component for performance optimization:

-export function ProjectListSkeleton() {
+export const ProjectListSkeleton = React.memo(function ProjectListSkeleton() {
 	// Component implementation
-}
+});

35-76: Consider responsive skeleton rows

The fixed number of skeleton rows (10) might be excessive on smaller screens.

Consider making the number of skeleton rows responsive based on screen size:

-{Array.from({ length: 10 }).map((_, index) => (
+{Array.from({ length: useResponsiveRowCount() }).map((_, index) => (

Where useResponsiveRowCount could be a custom hook that returns a different number based on viewport size:

function useResponsiveRowCount() {
  const [rowCount, setRowCount] = useState(10);
  
  useEffect(() => {
    const handleResize = () => {
      if (window.innerWidth < 640) {
        setRowCount(5);
      } else {
        setRowCount(10);
      }
    };
    
    handleResize();
    window.addEventListener('resize', handleResize);
    return () => window.removeEventListener('resize', handleResize);
  }, []);
  
  return rowCount;
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5af3157 and 6e315e1.

📒 Files selected for processing (2)
  • apps/web/app/[locale]/projects/components/project-views/list-view/data-table.tsx (2 hunks)
  • apps/web/app/[locale]/projects/components/project-views/list-view/list-skeleton.tsx (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
apps/web/app/[locale]/projects/components/project-views/list-view/data-table.tsx (1)
apps/web/app/[locale]/projects/components/project-views/list-view/list-skeleton.tsx (1)
  • ProjectListSkeleton (4-82)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: deploy
🔇 Additional comments (7)
apps/web/app/[locale]/projects/components/project-views/list-view/data-table.tsx (4)

37-37: LGTM! Proper import of the new skeleton component

The import statement correctly references the new skeleton component from the local directory.


468-468: Great UX improvement with skeleton loading

Replacing the spinner with a skeleton loading state provides users with a better visual indication of the content structure while data is being fetched.


470-470: UI consistency enhancement

Adding a border to the table container ensures visual consistency between the skeleton state and the loaded data view.


31-31:

✅ Verification successful

Confirm unused import

The HorizontalSeparator import has been added, but it appears to only be used in the dropdown menu component and was likely already present in the file. Check if this is a new addition or if the diff is showing it as changed when it wasn't.


🏁 Script executed:

#!/bin/bash
# Check if HorizontalSeparator was already imported in previous versions
git show HEAD~1:apps/web/app/[locale]/projects/components/project-views/list-view/data-table.tsx | grep -n "import.*HorizontalSeparator"

Length of output: 214


HorizontalSeparator import is confirmed as pre-existing

  • The previous version imported { HorizontalSeparator, SpinnerLoader } (line 31), and the current diff only removes SpinnerLoader.
  • This confirms that HorizontalSeparator was already part of the file and isn’t a new addition.
  • If the removal of SpinnerLoader was unintentional, please verify its usage in the dropdown menu component; otherwise, no changes are needed regarding HorizontalSeparator.
apps/web/app/[locale]/projects/components/project-views/list-view/list-skeleton.tsx (3)

1-3: LGTM! Proper imports for skeleton component

All necessary components are imported correctly.


4-33: Well-structured table header skeleton

The table header skeleton effectively mimics the actual table structure with appropriate column widths and placeholder elements.


34-77: Comprehensive row skeleton implementation

The table body implementation creates a realistic loading state with appropriate skeleton elements for each type of data. The use of Array.from to generate multiple skeleton rows is efficient.

- Added back navigation arrow in timesheet detail view
- Implemented breadcrumb navigation for better user orientation
- Added proper dark mode support for navigation elements
- Maintained consistent spacing and alignment with flex layout
- Ensured responsive design with proper height constraints
@evereq evereq merged commit 10de2ea into develop Apr 4, 2025
15 of 16 checks passed
@evereq evereq deleted the feat/project-list-skeleton branch April 4, 2025 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants