Skip to content
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

improved carousal #365

Closed
wants to merge 1 commit into from
Closed

Conversation

STXRSHIVA
Copy link

@STXRSHIVA STXRSHIVA commented Oct 20, 2024

before :

Screen.Recording.2024-10-20.162757.mp4

after :

Screen.Recording.2024-10-20.162934.mp4

fixes : #302

Summary by CodeRabbit

  • New Features

    • Introduced automatic slide transitions in the ReviewCarousel.
    • Enhanced responsiveness by adapting the number of visible reviews based on screen width.
  • Bug Fixes

    • Adjusted slide reset conditions for improved navigation through reviews.
  • Style

    • Minor formatting updates for consistency in the component structure.

Copy link

vercel bot commented Oct 20, 2024

@STXRSHIVA is attempting to deploy a commit to the bunty's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Oct 20, 2024

Walkthrough

The ReviewCarousel component has been modified to enhance its functionality and responsiveness. Key changes include adjustments to slide transition logic, the introduction of an automatic slide change feature, and a new state variable cardsToShow that adapts based on window width. The reset condition for currentIndex has been altered, and an interval for automatic transitions every 3 seconds has been implemented. Minor formatting adjustments were also made to the JSX structure.

Changes

File Change Summary
frontend/src/components/ui/ReviewCarousel.jsx - Updated slide transition logic and reset condition for currentIndex.
- Introduced cardsToShow state variable and updateCardsToShow function.
- Added automatic slide change feature with interval.
- Minor formatting changes in JSX.

Possibly related PRs

  • Fixed the About and review carousel section #47: This PR includes changes to the ReviewCarousel component, specifically updating the layout and functionality, which aligns with the modifications made in the main PR regarding the carousel's behavior and responsiveness.
  • Added animated testimonial section #351: This PR also modifies the ReviewCarousel component, introducing significant structural changes and an automatic slide transition feature, which relates closely to the automatic slide change feature implemented in the main PR.

Suggested labels

level2, gssoc-ext, checked

Suggested reviewers

  • RamakrushnaBiswal

Poem

In the carousel, round we go,
With reviews that dance and flow.
A change of slides, oh what a sight,
Automatic spins, day and night!
Responsive to the screen's embrace,
Hoppy joy in every space! 🐰✨


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 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
Contributor

Thank you for submitting your pull request! 🙌 We'll review it as soon as possible. In the meantime, please ensure that your changes align with our CONTRIBUTING.md. If there are any specific instructions or feedback regarding your PR, we'll provide them here. Thanks again for your contribution! 😊

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

🧹 Outside diff range and nitpick comments (1)
frontend/src/components/ui/ReviewCarousel.jsx (1)

Line range hint 126-128: Enhance accessibility by improving the alt text for images.

The alt attribute currently uses ${index}img, which is not descriptive. For better accessibility, it's important to provide meaningful alternative text:

<LazyLoadImage
-  alt={`${index}img`}
+  alt={`${review.name}'s profile picture`}
   effect="blur"
   className="w-20 h-20 rounded-full"
   ...
/>

This change helps users who rely on screen readers to have a better understanding of the content.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 76a5b4d and d47c023.

📒 Files selected for processing (1)
  • frontend/src/components/ui/ReviewCarousel.jsx (4 hunks)
🧰 Additional context used
🔇 Additional comments (2)
frontend/src/components/ui/ReviewCarousel.jsx (2)

114-115: Layout adjustments enhance responsiveness on smaller screens.

The addition of overflow-x-auto and md:overflow-hidden improves the carousel's responsiveness. On smaller screens, it allows horizontal scrolling, while on medium and larger screens, it hides the overflow, providing a cleaner layout.


172-172: Navigation buttons are appropriately displayed based on screen size.

By adding hidden and md:block classes, the navigation buttons are hidden on small screens and shown on medium and larger screens. This enhances the user experience by simplifying the interface on mobile devices where swipe gestures are common.

Comment on lines +74 to 76
prevIndex === reviews.length - 6 ? 0 : prevIndex + 1
);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Consider making the slide reset condition dynamic based on cardsToShow.

The current reset condition in nextSlide uses a hardcoded value reviews.length - 6, which may not accurately reflect the number of cards to show when cardsToShow changes. This could lead to unexpected behavior, especially if the number of reviews or the cardsToShow value changes in the future.

To ensure correct functionality, adjust the reset condition to depend on cardsToShow:

setCurrentIndex((prevIndex) =>
-  prevIndex === reviews.length - 6 ? 0 : prevIndex + 1
+  prevIndex === reviews.length - cardsToShow ? 0 : prevIndex + 1
);

This change makes the carousel dynamically adapt to the number of cards displayed.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
prevIndex === reviews.length - 6 ? 0 : prevIndex + 1
);
};
prevIndex === reviews.length - cardsToShow ? 0 : prevIndex + 1
);
};

Comment on lines +80 to 82
prevIndex === 0 ? reviews.length - 6 : prevIndex - 1
);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Update prevSlide reset condition to use cardsToShow dynamically.

Similar to nextSlide, the prevSlide function uses a hardcoded value which may not align with the dynamic cardsToShow state. Adjusting the reset condition will ensure consistency and correct navigation:

setCurrentIndex((prevIndex) =>
-  prevIndex === 0 ? reviews.length - 6 : prevIndex - 1
+  prevIndex === 0 ? reviews.length - cardsToShow : prevIndex - 1
);

This change ensures that the previous slide logic correctly accounts for the number of cards displayed.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
prevIndex === 0 ? reviews.length - 6 : prevIndex - 1
);
};
prevIndex === 0 ? reviews.length - cardsToShow : prevIndex - 1
);
};

Comment on lines +98 to 102
const intervalId = setInterval(nextSlide, 3000); // Change slide every 3 seconds

return () => {
clearInterval(intervalId); // Cleanup interval on unmount
window.removeEventListener('resize', updateCardsToShow);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Ensure nextSlide uses the latest cardsToShow value within the interval.

Since cardsToShow can change due to window resizing, the nextSlide function inside the setInterval may capture an outdated value of cardsToShow due to closure scope. This can lead to incorrect slide transitions after a resize.

Consider the following options to ensure nextSlide always has the latest cardsToShow:

  • Option 1: Include cardsToShow in the dependency array of the useEffect:

    useEffect(() => {
      updateCardsToShow();
      window.addEventListener('resize', updateCardsToShow);
    
      const intervalId = setInterval(nextSlide, 3000); // Change slide every 3 seconds
    
      return () => {
        clearInterval(intervalId); // Cleanup interval on unmount
        window.removeEventListener('resize', updateCardsToShow);
      };
    -}, []);
    +}, [cardsToShow]);
  • Option 2: Use a functional update in setInterval to ensure the latest state is used.

Committable suggestion was skipped due to low confidence.

@RamakrushnaBiswal
Copy link
Owner

#351 solved

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.

improve slideshow
2 participants