-
-
Notifications
You must be signed in to change notification settings - Fork 100
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThis pull request introduces modifications to two components: Changes
Possibly related PRs
Suggested reviewers
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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! 😊 |
There was a problem hiding this 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:
- Use list elements for the hours instead of line breaks.
- 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" functionalityThe new state variable
showMoreStates
and thetoggleShowMore
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" functionalityThe 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
📒 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 textThe review text for Jane Smith has been simplified, improving readability without losing the essence of the feedback.
44-44
: LGTM: Improved review textsThe 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 adjustmentsThe 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 stylingThe class attribute for the image element has been simplified, improving code readability while maintaining the essential styling.
139-139
: LGTM: Consistent class orderingThe 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 componentThe changes to the ReviewCarousel component significantly enhance its functionality and user experience. Key improvements include:
- Implementation of a "Read more" feature for reviews
- Layout adjustments for better responsiveness
- 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:
- Test the component with reviews of varying lengths to verify the "Read more" functionality.
- Check the layout on different screen sizes to confirm responsiveness.
- Verify that the carousel navigation works correctly with different numbers of reviews.
Great work on improving this component!
hi @sajalbatra |
Hey, |
@sajalbatra |
There was a problem hiding this 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
📒 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 correctlyThe addition of the
showMoreStates
state variable and thetoggleShowMore
function correctly implements the expandable review text feature.
<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> |
There was a problem hiding this comment.
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.
<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> |
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); | ||
}; | ||
}, []); |
There was a problem hiding this comment.
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:
-
Remove the
cardsToShow
state and theupdateCardsToShow
function (lines 78-95). -
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" >
-
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.
Fixed the things
Summary by CodeRabbit
New Features
Bug Fixes
Style