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

Added splide js #233

Merged
merged 9 commits into from
Oct 12, 2024
Merged

Added splide js #233

merged 9 commits into from
Oct 12, 2024

Conversation

Shirisha-16
Copy link
Contributor

@Shirisha-16 Shirisha-16 commented Oct 11, 2024

Summary by CodeRabbit

  • New Features

    • Introduced an image carousel for displaying board game images, enhancing visual presentation.
    • Added lazy loading for improved performance.
    • Added a navigation link in the signup component for users to easily log in if they already have an account.
  • Chores

    • Updated project dependencies to include @splidejs/react-splide.

Copy link

vercel bot commented Oct 11, 2024

@Shirisha-16 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

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 bot commented Oct 11, 2024

Walkthrough

The pull request introduces a new dependency, @splidejs/react-splide, to the package.json file of the boardgame-cafe project. It modifies the Boardgame component to implement a carousel for displaying images of board games using the newly added Splide components, featuring automatic looping, lazy loading, and auto-scrolling. The Signup component is updated to include a navigation link for existing users, enhancing the user interface while maintaining the existing structure and functionality.

Changes

File Change Summary
frontend/package.json Added dependency: "@splidejs/react-splide": "^0.7.12"
frontend/src/components/Pages/Boardgame.jsx Integrated Splide, SplideSlide, and AutoScroll components for an image carousel; updated imports; replaced background image handling with carousel implementation.
frontend/src/components/Pages/Signup.jsx Added import for Link from react-router-dom and included a navigation link for existing users.

Possibly related PRs

Suggested labels

enhancement, level 2, gssoc-ext

Suggested reviewers

  • RamakrushnaBiswal

Poem

🐇 In a cafe where board games play,
A carousel spins, brightening the day.
Images slide with a gentle grace,
Come join the fun, find your place!
With lazy loads, the view’s a delight,
Hop on in, let’s play tonight! 🎲✨


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

@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

🧹 Outside diff range and nitpick comments (4)
frontend/package.json (1)

16-16: LGTM! Consider adding Splide CSS import.

The addition of @splidejs/react-splide is appropriate for implementing a carousel/slider component in this React project. The version ^0.7.12 allows for automatic minor updates, which is good for keeping the package up-to-date with bug fixes.

Don't forget to import the Splide CSS in your React component or main CSS file:

import '@splidejs/react-splide/css';
// or
import '@splidejs/react-splide/css/skyblue';
import '@splidejs/react-splide/css/sea-green';
// or
import '@splidejs/react-splide/css/core';

This ensures that the Splide components are styled correctly.

frontend/src/components/Pages/Boardgame.jsx (3)

224-267: Splide carousel implementation looks great, with a minor suggestion.

The Splide carousel is well-implemented with appropriate configuration for looping, autoplay, and lazy loading. The use of LazyLoadImage components within SplideSlides is a good practice for optimizing image loading.

Consider improving the alt text for the images to be more descriptive. For example, instead of "bg", "bg1", etc., use descriptions that convey the content of each image, such as "Board game setup on a wooden table" or "Group of friends playing a strategy game".


303-332: Newsletter subscription section looks good, with a suggestion for improvement.

The subscription form is well-implemented with proper input validation and event handling.

Consider adding visual feedback to the user after form submission. This could be a success message or an error message, depending on the result of the API call. You could use a state variable to control the display of these messages. For example:

const [submitStatus, setSubmitStatus] = useState(null);

const handleSubmit = async (e) => {
  e.preventDefault();
  try {
    // ... existing code ...
    setSubmitStatus('success');
  } catch (error) {
    console.error('Error subscribing to newsletter:', error);
    setSubmitStatus('error');
  }
};

// In your JSX, after the form:
{submitStatus === 'success' && (
  <p className="text-green-500 mt-2">Successfully subscribed!</p>
)}
{submitStatus === 'error' && (
  <p className="text-red-500 mt-2">Error subscribing. Please try again.</p>
)}

This would provide immediate feedback to the user about the result of their subscription attempt.


Line range hint 1-359: Overall structure is good, with a suggestion for data management.

The component structure is well-organized, and the addition of the Splide carousel enhances the visual appeal. The use of lazy loading for carousel images is good for performance.

Consider moving the boards array to a separate file or fetching it from an API. This would improve maintainability and scalability, especially if the dataset grows or needs to be shared across components. You could implement this as follows:

  1. Create a new file boardData.js:
export const boards = [
  // ... your board data ...
];
  1. In your Boardgame component, import and use the data:
import { boards } from './boardData';

export default function Boardgame() {
  // ... rest of your component ...
}

This separation of concerns would make the component more focused on rendering and interaction, while keeping the data management separate.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6102828 and 6808f0d.

📒 Files selected for processing (2)
  • frontend/package.json (1 hunks)
  • frontend/src/components/Pages/Boardgame.jsx (3 hunks)
🧰 Additional context used
🔇 Additional comments (3)
frontend/src/components/Pages/Boardgame.jsx (3)

2-3: LGTM: Splide library integration looks good.

The addition of Splide components and their corresponding CSS is a good choice for implementing an image carousel. The imports are correctly placed and the library is used appropriately in the component.


270-302: LGTM: Board game display section is well-maintained.

The existing implementation for displaying board games is preserved, which maintains consistency in the user interface. The use of hover effects, the "See Instructions" button, and the responsive grid layout provide a good user experience across different devices.


Line range hint 1-359: Summary: Excellent enhancements to the Boardgame component

The changes introduced in this PR significantly improve the visual appeal and user experience of the Boardgame component, particularly with the addition of the Splide carousel. The existing functionality has been well-preserved, maintaining consistency in the user interface.

Key points:

  1. The Splide carousel is well-implemented with appropriate configuration.
  2. Lazy loading of images is a good performance optimization.
  3. The board game display section and newsletter subscription form are maintained effectively.

Suggestions for further improvement:

  1. Enhance image accessibility by using more descriptive alt text.
  2. Add user feedback for the newsletter subscription form submission.
  3. Consider moving the board game data to a separate file for better maintainability.

Overall, this is a solid improvement to the component. Great job!

Copy link

vercel bot commented Oct 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
play-cafe ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 12, 2024 0:55am
play-cafe-backen ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 12, 2024 0:55am

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

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

230-273: Splide carousel implementation looks good, with some suggestions for improvement

The Splide carousel has been implemented correctly with appropriate configuration options. However, consider the following suggestions:

  1. The use of external image URLs (e.g., from unsplash.com) may pose a risk if these URLs become invalid in the future. Consider hosting these images locally or using a more stable CDN.

  2. The alt text for the images (e.g., "bg", "bg1", "bg2") could be more descriptive to improve accessibility. Use meaningful descriptions that convey the content of each image.

  3. The className for the Splide component includes Tailwind classes that may not be necessary for Splide's functionality. Review if all these classes are needed:

    className="mx-auto w-full rounded-t-xl object-cover object-center shadow-2xl"

Consider implementing these suggestions to improve the robustness and accessibility of the carousel.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6808f0d and 7b2cfaa.

📒 Files selected for processing (2)
  • frontend/package.json (1 hunks)
  • frontend/src/components/Pages/Boardgame.jsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/package.json
🧰 Additional context used
🔇 Additional comments (3)
frontend/src/components/Pages/Boardgame.jsx (3)

1-3: LGTM: Import statements updated correctly

The import statements have been appropriately updated to include the Splide components and styles, which are necessary for the new carousel implementation. The removal of the unused useEffect import is also a good cleanup.


Line range hint 1-373: Overall assessment: Good implementation with minor improvements needed

The implementation of the Splide carousel enhances the visual appeal of the Boardgame page. The code changes are generally well-structured and follow good practices. However, there are a few areas that could be improved:

  1. Consider hosting carousel images locally or using a stable CDN to prevent potential issues with external URLs.
  2. Improve the alt text for carousel images to enhance accessibility.
  3. Review the Tailwind classes used for the Splide component to ensure they are all necessary.
  4. Clarify the reason for removing the useEffect hook for scrolling to the top of the page, and consider reimplementing it if needed.

Addressing these points will further improve the code quality and user experience of the Boardgame page.


208-209: ⚠️ Potential issue

Clarify the removal of useEffect for scrolling

The useEffect hook for scrolling to the top of the page has been removed:

useEffect(() => {
  window.scrollTo(0, 0);
}, []);

This might affect the user experience when navigating to this page. Could you please clarify why this was removed? If there's an alternative mechanism in place for ensuring the page starts at the top when loaded, please explain it. If not, consider reimplementing this functionality to maintain a consistent user experience.

To check if this functionality is implemented elsewhere, we can search for similar scroll-to-top logic in other components:

@RamakrushnaBiswal
Copy link
Owner

RamakrushnaBiswal commented Oct 12, 2024

@Shirisha-16 make the height of the images little bit small

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

🧹 Outside diff range and nitpick comments (3)
frontend/src/components/Pages/Boardgame.jsx (3)

1-3: Remove unused import

The useEffect import is no longer used in this component. Consider removing it to keep the imports clean and avoid potential confusion.

Apply this diff to remove the unused import:

-import React, { useState,useEffect  } from 'react';
+import React, { useState } from 'react';

230-273: Splide carousel implementation looks good, with room for minor improvements

The Splide carousel implementation is well done, with autoplay and lazy loading enabled for better performance and user experience. However, consider the following suggestions for improvement:

  1. Extract the Splide options into a separate constant for better readability and maintainability.
  2. Consider using a map function to generate SplideSlides from an array of image URLs, which would make it easier to add or remove slides in the future.

Here's an example of how you could refactor this section:

const splideOptions = {
  type: 'loop',
  perPage: 1,
  autoplay: true,
  interval: 3000,
  lazyLoad: 'sequential',
};

const backgroundImages = [
  "https://images.unsplash.com/photo-1656686631034-e88d4fbde1e3?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
  "https://images.unsplash.com/photo-1681402720847-961bb1aab8d8?q=80&w=2071&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
  "https://images.unsplash.com/photo-1609818698346-8cb3be6e0bc0?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
  "https://images.unsplash.com/photo-1659480142923-0cd01191e0e9?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
];

// In the return statement:
<Splide
  options={splideOptions}
  className="mx-auto w-full rounded-t-xl object-cover object-center shadow-2xl"
>
  {backgroundImages.map((src, index) => (
    <SplideSlide key={index}>
      <LazyLoadImage
        alt={`bg${index}`}
        effect="blur"
        src={src}
        className="w-full h-full object-cover"
      />
    </SplideSlide>
  ))}
</Splide>

This refactoring improves code organization and makes it easier to maintain and update the carousel in the future.


Line range hint 1-365: Overall changes look good, consider performance optimizations

The addition of the Splide carousel enhances the visual appeal of the component without disrupting existing functionality. However, to further improve performance, consider the following suggestions:

  1. Implement lazy loading for the board game images in the grid. This can be achieved using the LazyLoadImage component you're already using for the carousel.
  2. Consider implementing pagination or infinite scrolling for the board game grid to reduce the initial load time, especially if the list of games is expected to grow.
  3. Optimize the images used in the carousel and the board game grid. Ensure they are properly sized and compressed for web use.

Here's an example of how you could implement lazy loading for the board game images:

import { LazyLoadImage } from 'react-lazy-load-image-component';

// In the board game grid mapping
{boards.map((board, index) => (
  <div key={index} className="...">
    <div className="relative overflow-hidden">
      <LazyLoadImage
        src={board.src}
        alt={board.title}
        effect="blur"
        width={500}
        height={400}
        className="object-cover w-full h-48 transition-all duration-300 ease-in-out group-hover:h-32"
      />
      {/* ... rest of the card content ... */}
    </div>
  </div>
))}

This change will help improve the initial load time of the page, especially for users with slower internet connections.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 7b2cfaa and 62a57b1.

📒 Files selected for processing (1)
  • frontend/src/components/Pages/Boardgame.jsx (4 hunks)
🧰 Additional context used

Comment on lines +208 to 211

useEffect(() => {
window.scrollTo(0, 0);
}, []);
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

Remove unused useEffect hook

The useEffect hook is no longer being used in this component. It's best to remove unused code to keep the component clean and avoid potential confusion or performance issues.

Apply this diff to remove the unused useEffect hook:

-  useEffect(() => {
-    window.scrollTo(0, 0);
-  }, []);
📝 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
useEffect(() => {
window.scrollTo(0, 0);
}, []);

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

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

122-127: LGTM: Improved UX with login link for existing users.

The addition of this section enhances the user experience by providing a clear path for existing users to navigate to the login page. The styling is consistent with the rest of the component, and the hover effects add a nice touch.

Consider adding an aria-label to the Link component for improved accessibility. For example:

- <Link to={'/login'}>Login</Link>
+ <Link to={'/login'} aria-label="Go to login page">Login</Link>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 62a57b1 and 40ef958.

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

5-5: LGTM: Appropriate import for navigation.

The addition of the Link import from react-router-dom is correct and necessary for the new navigation feature added to the form.


Line range hint 1-141: Summary: Beneficial addition of login link for existing users.

The changes in this file are minimal but impactful. The addition of the login link for existing users improves the overall user experience and navigation flow of the application. The implementation is clean, consistent with the existing code style, and doesn't introduce any apparent issues.

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

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

250-250: Consider using responsive units for image dimensions

The image dimensions are currently hardcoded in pixels, which might not be ideal for responsiveness across different screen sizes.

Consider using responsive units or CSS classes for the image dimensions. For example:

- style={{height : "500px" ,width:"2000px"}}
+ className="w-full h-[500px] object-cover"

This change allows the width to adapt to the container while maintaining the aspect ratio.

Also applies to: 259-259, 268-268, 277-277

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 40ef958 and c001666.

📒 Files selected for processing (1)
  • frontend/src/components/Pages/Boardgame.jsx (4 hunks)
🧰 Additional context used
🔇 Additional comments (5)
frontend/src/components/Pages/Boardgame.jsx (5)

1-4: LGTM: New imports for Splide carousel

The new imports for Splide components and styles are correctly added and necessary for the carousel functionality.


231-281: LGTM: Splide carousel implementation

The Splide carousel is well-implemented with appropriate options for looping, autoplay, lazy loading, and auto-scrolling. The use of LazyLoadImage within SplideSlide components is a good practice for performance optimization.


Line range hint 282-359: LGTM: Boardgame cards section

The boardgame cards section remains unchanged and continues to provide a good user interface for displaying the game collection.


Line range hint 360-373: LGTM: Newsletter form and instructions modal

The newsletter subscription form and instructions modal sections remain unchanged. The email state management and form submission logic are correctly implemented, providing a good user experience for newsletter sign-ups and displaying game instructions.


Line range hint 1-373: Overall assessment: Successful integration of Splide carousel

The changes in this file primarily focus on implementing a Splide carousel for background images, which enhances the visual appeal of the Boardgame component. The integration is well-executed, following good practices such as lazy loading and appropriate configuration options.

The existing functionality of the component, including the boardgame cards display, newsletter subscription, and game instructions modal, remains intact and continues to provide a good user experience.

There are a few minor improvements that could be made:

  1. Removing the unused useEffect hook.
  2. Enhancing the responsiveness of the carousel images.

These changes successfully add a new feature without disrupting the existing structure and functionality of the component.

Comment on lines +209 to 211

useEffect(() => {
window.scrollTo(0, 0);
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

Remove unused useEffect hook

The useEffect hook is no longer being used in this component. It's best to remove unused code to keep the component clean and avoid potential confusion.

Apply this diff to remove the unused useEffect hook:

-  useEffect(() => {
-    window.scrollTo(0, 0);
-  }, []);
📝 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
useEffect(() => {
window.scrollTo(0, 0);

@Shirisha-16
Copy link
Contributor Author

i have changed the height of images and added autoscroll as well. I have completed another task under this (Addition of login link in signup page).

@RamakrushnaBiswal RamakrushnaBiswal added gssoc-ext gssoc-extd program hacktoberfest accepted hacktoberfest-accepted repo labels Oct 12, 2024
@RamakrushnaBiswal RamakrushnaBiswal merged commit a462317 into RamakrushnaBiswal:main Oct 12, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request gssoc-ext gssoc-extd program hacktoberfest accepted hacktoberfest-accepted repo level2 for 25 points
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants