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

Fixed the About and review carousel section #47

Merged
merged 4 commits into from
Oct 3, 2024
Merged

Fixed the About and review carousel section #47

merged 4 commits into from
Oct 3, 2024

Conversation

sajalbatra
Copy link
Contributor

@sajalbatra sajalbatra commented Oct 3, 2024

Fixed the things
image
image
image

Summary by CodeRabbit

  • New Features

    • Enhanced layout and styling of the About component for improved visual presentation.
    • Introduced a "Read more" functionality in the ReviewCarousel for displaying full reviews or truncated versions based on user interaction.
    • Dynamic adjustment of displayed reviews in the ReviewCarousel based on window width.
  • Bug Fixes

    • Improved readability of review text by consolidating multiline strings.
  • Style

    • Adjusted CSS classes and layout properties for better consistency and responsiveness across components.
    • Updated class names for the About component to enhance text contrast and responsiveness.

Copy link

vercel bot commented Oct 3, 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 3, 2024 4:16pm
play-cafe-bsbl ❌ Failed (Inspect) Oct 3, 2024 4:16pm

Copy link
Contributor

coderabbitai bot commented Oct 3, 2024

Walkthrough

This pull request introduces modifications to two components: About and ReviewCarousel. In the About component, the layout and styling have been refined with new div wrappers and class name adjustments to enhance visual presentation. The ReviewCarousel component has seen improvements in readability and functionality, including the introduction of state variables for toggling review visibility and managing the number of displayed cards, along with adjustments to the layout and CSS classes for consistency.

Changes

File Change Summary
frontend/src/components/Pages/About.jsx Updated import statement, rearranged class names, added new div wrappers, improved layout with flexbox, and added comment for overlay opacity.
frontend/src/components/ui/ReviewCarousel.jsx Consolidated multiline strings, added showMoreStates and cardsToShow state variables, introduced toggleShowMore and updateCardsToShow functions, and adjusted layout and CSS classes for consistency.

Possibly related PRs

  • fixed the path for bgpic in About.jsx #3: The changes in this PR involve updating the import statement for the background image in the About.jsx file, which directly relates to the modifications made in the main PR regarding the About component.

Suggested reviewers

  • RamakrushnaBiswal

Poem

🐰 In the land of code where rabbits play,
The About page shines brighter today.
With flexbox magic and styles anew,
The ReviewCarousel hops, showing more too!
So let’s celebrate with a joyful cheer,
For every change brings us closer, my dear! 🌟


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

github-actions bot commented Oct 3, 2024

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

🧹 Outside diff range and nitpick comments (6)
frontend/src/components/Pages/About.jsx (4)

1-1: Consider removing the semicolon after the import statement.

While not incorrect, the semicolon after the import statement is unnecessary in modern JavaScript, especially when using ES6 modules. Removing it would align better with common JavaScript style guides and maintain consistency with other files in the project.

-import bgpic from "../../assets/img/abt1.jpg";
+import bgpic from "../../assets/img/abt1.jpg"

7-11: LGTM! Consider enhancing the overlay comment.

The changes to the background image container and overlay improve the structure and readability of the code. The added comment provides clarity about the overlay's purpose.

Consider updating the comment to be more specific about the CSS property used:

-        {/* Black overlay with 60% opacity */}
+        {/* Black overlay with 60% opacity (using opacity-60 Tailwind class) */}

This change would provide more precise information about how the opacity is achieved.


14-20: LGTM! Consider adding an aria-label for improved accessibility.

The changes to the content container and title improve the layout's responsiveness and ensure proper alignment across different screen sizes. The progressive increase in font size is a good responsive design practice.

Consider adding an aria-label to the title for improved accessibility:

-          <div className="flex items-center justify-center md:w-1/2">
+          <div className="flex items-center justify-center md:w-1/2" aria-label="About Us Section">

This change would provide more context for screen readers and improve the overall accessibility of the component.


Line range hint 23-48: LGTM on layout. Consider improving content formatting.

The changes to the paragraph container improve alignment and readability. The use of gray-200 for text color provides better contrast against the dark background.

Consider improving the content formatting for better readability:

  1. Use list elements for the hours instead of line breaks.
  2. Add more semantic structure to the content.

Here's a suggested refactor:

<div className="relative z-10 flex justify-center w-full mt-10 align-middle md:pl-32">
  <div className="text-gray-200 text-l md:text-xl">
    <h2 className="text-2xl font-bold mb-4">How it works</h2>
    <p className="mb-4">
      Our name says it all! Founder, Jonathan Li, shares a passion for board games, boba, and
      delicious food, so he combined them all to become Sip & Play, Park Slope's
      first board game cafe. It is a straightforward concept, come in with your
      friends and family to play any board game from our library of <span className="text-amber-600">300+ games!</span>
      We hope when you visit, you also enjoy our coffee, espresso, boba,
      sandwiches, and snacks!
    </p>
    <h2 className="text-2xl font-bold mb-2">Hours and Location</h2>
    <p className="mb-2">New opening hours:</p>
    <ul className="list-disc list-inside mb-4">
      <li>Sunday: 10am-11pm</li>
      <li>Mon-Thurs: 11am-11pm</li>
      <li>Fri: 11am-midnight</li>
      <li>Sat: 10am-midnight</li>
    </ul>
    <p>Our kitchen closes 2.5-3 hours before we close!</p>
  </div>
</div>

This refactoring improves the structure and readability of the content while maintaining the existing styling.

frontend/src/components/ui/ReviewCarousel.jsx (2)

57-65: LGTM: Added "Read more" functionality

The new state variable showMoreStates and the toggleShowMore function effectively implement the "Read more" feature for each review. This enhances user experience by allowing users to expand longer reviews.

Consider a minor optimization:

 const toggleShowMore = (index) => {
-  const updatedStates = [...showMoreStates];
-  updatedStates[index] = !updatedStates[index];
-  setShowMoreStates(updatedStates);
+  setShowMoreStates(prevStates => {
+    const updatedStates = [...prevStates];
+    updatedStates[index] = !updatedStates[index];
+    return updatedStates;
+  });
 };

This change uses the functional update form of setShowMoreStates, ensuring that you're always working with the most current state.


118-127: LGTM: Implemented "Read more" functionality

The new logic for conditionally displaying full or truncated review text is well-implemented. It correctly uses the showMoreStates and provides a toggle for users to expand or collapse the review text.

Consider making the truncation length dynamic based on the review length or screen size. For example:

const truncateLength = Math.min(50, Math.floor(review.review.length / 2));
`${review.review.substring(0, truncateLength)}...`

This approach ensures that very short reviews aren't unnecessarily truncated while still providing a "Read more" option for longer reviews.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 812389f and 1b0449a.

📒 Files selected for processing (2)
  • frontend/src/components/Pages/About.jsx (1 hunks)
  • frontend/src/components/ui/ReviewCarousel.jsx (5 hunks)
🔇 Additional comments (7)
frontend/src/components/Pages/About.jsx (1)

5-5: LGTM! Verify layout with new margin on medium screens.

The changes to the main container improve the responsiveness of the component. The use of Tailwind CSS classes is consistent and follows best practices.

Please verify that the md:mt-28 class (which adds a top margin of 7rem on medium screens and larger) doesn't cause any unexpected layout issues or overlap with other components.

frontend/src/components/ui/ReviewCarousel.jsx (6)

8-8: LGTM: Simplified review text

The review text for Jane Smith has been simplified, improving readability without losing the essence of the feedback.


44-44: LGTM: Improved review texts

The review texts for Olivia Green and Ethan White have been refined, enhancing readability while maintaining the essence of their feedback.

Also applies to: 50-50


87-88: LGTM: Layout adjustments

The changes to the component's structure appear to improve its responsiveness and appearance. The modifications to height, width, and padding seem reasonable.

Please verify that these layout changes render correctly across different screen sizes. Consider adding responsive design tests or screenshots to the PR to demonstrate the improvements.

Also applies to: 99-99, 101-101


106-106: LGTM: Simplified image styling

The class attribute for the image element has been simplified, improving code readability while maintaining the essential styling.


139-139: LGTM: Consistent class ordering

The reordering of classes in the navigation buttons improves consistency in the codebase. This change doesn't affect functionality but enhances code readability.

Also applies to: 145-145


Line range hint 1-156: Overall LGTM: Improved ReviewCarousel component

The changes to the ReviewCarousel component significantly enhance its functionality and user experience. Key improvements include:

  1. Implementation of a "Read more" feature for reviews
  2. Layout adjustments for better responsiveness
  3. Simplified and consistent styling

These modifications make the component more interactive and visually appealing. The code remains clean and well-structured.

To ensure the changes work as intended across different scenarios:

  1. Test the component with reviews of varying lengths to verify the "Read more" functionality.
  2. Check the layout on different screen sizes to confirm responsiveness.
  3. Verify that the carousel navigation works correctly with different numbers of reviews.

Great work on improving this component!

@RamakrushnaBiswal
Copy link
Owner

hi @sajalbatra
image
don't change this in large and md screen size (keep as it is) in mobile view its good
other's are good

@RamakrushnaBiswal RamakrushnaBiswal added gssoc-ext gssoc-extd program checked i am reviewed the PR level2 for 25 points labels Oct 3, 2024
@sajalbatra
Copy link
Contributor Author

hi @sajalbatra image don't change this in large and md screen size (keep as it is) in mobile view its good other's are good

Hey,
Please check again i have fixed the top margin

@RamakrushnaBiswal
Copy link
Owner

image
i mean don't change it in large and md screen just make change in small screen

@RamakrushnaBiswal
Copy link
Owner

@sajalbatra
image
make it responsive

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 76ad810 and 1c525d0.

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

57-65: Approved: "Read more"/"Show less" functionality implemented correctly

The addition of the showMoreStates state variable and the toggleShowMore function correctly implements the expandable review text feature.

Comment on lines +136 to 146
<p className="text-lg leading-6 tracking-wide text-center">
{showMoreStates[index]
? review.review
: `${review.review.substring(0, 50)}...`}
<span
className="text-blue-500 cursor-pointer"
onClick={() => toggleShowMore(index)}
>
{showMoreStates[index] ? " Show less" : " Read more"}
</span>
</p>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance accessibility by using a <button> for the toggle

Replacing the <span> with a <button> improves accessibility by providing proper semantics and focus handling for users navigating via keyboard or assistive technologies.

Here's the suggested change:

- <span
+ <button
     className="text-blue-500 cursor-pointer focus:outline-none"
     onClick={() => toggleShowMore(index)}
   >
     {showMoreStates[index] ? " Show less" : " Read more"}
- </span>
+ </button>
📝 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
<p className="text-lg leading-6 tracking-wide text-center">
{showMoreStates[index]
? review.review
: `${review.review.substring(0, 50)}...`}
<span
className="text-blue-500 cursor-pointer"
onClick={() => toggleShowMore(index)}
>
{showMoreStates[index] ? " Show less" : " Read more"}
</span>
</p>
<p className="text-lg leading-6 tracking-wide text-center">
{showMoreStates[index]
? review.review
: `${review.review.substring(0, 50)}...`}
<button
className="text-blue-500 cursor-pointer focus:outline-none"
onClick={() => toggleShowMore(index)}
>
{showMoreStates[index] ? " Show less" : " Read more"}
</button>
</p>

Comment on lines +78 to +95
const [cardsToShow, setCardsToShow] = useState(1);

const updateCardsToShow = () => {
if (window.innerWidth >= 768) {
setCardsToShow(4);
} else {
setCardsToShow(1);
}
};

useEffect(() => {
updateCardsToShow();
window.addEventListener("resize", updateCardsToShow);

return () => {
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.

🛠️ Refactor suggestion

Suggestion: Use Tailwind CSS classes for responsiveness instead of JavaScript

Currently, the component uses cardsToShow state and window resize event listeners to adjust the number of visible cards based on screen width. This adds complexity and potential performance overhead.

Consider leveraging Tailwind CSS's responsive design utilities to control the layout purely with CSS. This approach simplifies the code by removing the need for additional state and event listeners.

Here's how you can adjust the code:

  1. Remove the cardsToShow state and the updateCardsToShow function (lines 78-95).

  2. Adjust the container div to handle wrapping and item widths:

    <div
      className="flex transition-transform duration-300 ease-in-out"
    - style={{
    -   transform: `translateX(-${currentIndex * (100 / cardsToShow)}%)`,
    -   width: `${(reviews.length / cardsToShow) * 100}%`,
    - }}
    + className="flex flex-wrap"
    >
  3. Update the card container to adjust widths based on screen size:

    - className="w-full p-2 sm:w-1/2 md:w-1/3 lg:w-1/4"
    + className="p-2 w-full sm:w-1/2 md:w-1/3 lg:w-1/4"

This change allows the layout to respond to screen size without JavaScript, maintaining the existing design on large and medium screens as requested.

Committable suggestion was skipped due to low confidence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
checked i am reviewed the PR gssoc-ext gssoc-extd program level2 for 25 points
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants