-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
Created TodaysSpecial Carousel Component #424
Conversation
WalkthroughThe pull request introduces updates to the Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
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 (
|
@IkkiOcean is attempting to deploy a commit to the bunty's projects Team on Vercel. A member of the Team first needs to authorize it. |
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! 😊 |
@RamakrushnaBiswal kindly merge my pr soon. |
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: 3
🧹 Outside diff range and nitpick comments (1)
frontend/src/components/Pages/TodaysSpecial.jsx (1)
85-85
: Remove unnecessary leading space inclassName
In the
SpecialCard
component, there's an extra space at the beginning of theclassName
template literal, which is redundant.Apply this diff to clean up the code:
-className={` ${index % 2 === 0 ? 'bg-pink-100 dark:bg-amber-900' : 'bg-teal-100 dark:bg-amber-500'} p-4 rounded-lg shadow-lg max-w-xs text-center transition-transform duration-300 ease-in-out transform hover:scale-105 mx-2`} +className={`${index % 2 === 0 ? 'bg-pink-100 dark:bg-amber-900' : 'bg-teal-100 dark:bg-amber-500'} p-4 rounded-lg shadow-lg max-w-xs text-center transition-transform duration-300 ease-in-out transform hover:scale-105 mx-2`}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- frontend/package.json (1 hunks)
- frontend/src/components/Pages/TodaysSpecial.jsx (2 hunks)
🔇 Additional comments (3)
frontend/package.json (2)
34-34
: LGTM! Good choice for responsive design.The addition of
react-responsive
is appropriate for implementing the responsive carousel behavior across different screen sizes as specified in the requirements.
27-27
: Verify lucide-react version number.The specified version
0.454.0
appears to be incorrect as it's much higher than the latest stable release.frontend/src/components/Pages/TodaysSpecial.jsx (1)
Line range hint
1-213
: Overall, excellent implementation of theTodaysSpecial
componentThe component effectively showcases today's specials with smooth transitions and responsive design. The use of
useCallback
anduseEffect
hooks is appropriate, and the hover functionality enhances user interaction.
const nextSpecial = useCallback(() => { | ||
if (!isHovered) { // Only change if not hovering | ||
setIsTransitioning(true); | ||
setCurrentIndex((prevIndex) => { | ||
if (prevIndex === infiniteSpecials.length - 2) { | ||
setTimeout(() => { | ||
setIsTransitioning(false); | ||
setCurrentIndex(1); | ||
}, 500); | ||
return prevIndex; | ||
} | ||
return prevIndex + 1; | ||
}); | ||
} | ||
}, [isHovered]); |
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.
Ensure isTransitioning
resets to false
after each transition
In the nextSpecial
function, isTransitioning
is set to true
when the transition starts but isn't reset to false
in all cases. This might leave the carousel stuck in a transitioning state.
Apply this diff to reset isTransitioning
after each transition:
const nextSpecial = useCallback(() => {
if (!isHovered) {
setIsTransitioning(true);
setCurrentIndex((prevIndex) => {
if (prevIndex === infiniteSpecials.length - 2) {
setTimeout(() => {
setCurrentIndex(1);
setIsTransitioning(false);
}, 500);
return prevIndex;
}
+ setTimeout(() => {
+ setIsTransitioning(false);
+ }, 500);
return prevIndex + 1;
});
}
}, [isHovered]);
📝 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.
const nextSpecial = useCallback(() => { | |
if (!isHovered) { // Only change if not hovering | |
setIsTransitioning(true); | |
setCurrentIndex((prevIndex) => { | |
if (prevIndex === infiniteSpecials.length - 2) { | |
setTimeout(() => { | |
setIsTransitioning(false); | |
setCurrentIndex(1); | |
}, 500); | |
return prevIndex; | |
} | |
return prevIndex + 1; | |
}); | |
} | |
}, [isHovered]); | |
const nextSpecial = useCallback(() => { | |
if (!isHovered) { // Only change if not hovering | |
setIsTransitioning(true); | |
setCurrentIndex((prevIndex) => { | |
if (prevIndex === infiniteSpecials.length - 2) { | |
setTimeout(() => { | |
setIsTransitioning(false); | |
setCurrentIndex(1); | |
}, 500); | |
return prevIndex; | |
} | |
setTimeout(() => { | |
setIsTransitioning(false); | |
}, 500); | |
return prevIndex + 1; | |
}); | |
} | |
}, [isHovered]); |
const prevSpecial = useCallback(() => { | ||
if (!isHovered) { // Only change if not hovering | ||
setIsTransitioning(true); | ||
setCurrentIndex((prevIndex) => { | ||
if (prevIndex === 1) { | ||
setTimeout(() => { | ||
setIsTransitioning(false); | ||
setCurrentIndex(infiniteSpecials.length - 2); | ||
}, 500); | ||
return prevIndex; | ||
} | ||
return prevIndex - 1; | ||
}); | ||
} | ||
}, [isHovered]); |
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.
Ensure isTransitioning
resets to false
after each transition
Similarly, in the prevSpecial
function, isTransitioning
is set to true
but may not reset to false
in all scenarios, potentially causing unintended behavior.
Apply this diff to reset isTransitioning
after each transition:
const prevSpecial = useCallback(() => {
if (!isHovered) {
setIsTransitioning(true);
setCurrentIndex((prevIndex) => {
if (prevIndex === 1) {
setTimeout(() => {
setCurrentIndex(infiniteSpecials.length - 2);
setIsTransitioning(false);
}, 500);
return prevIndex;
}
+ setTimeout(() => {
+ setIsTransitioning(false);
+ }, 500);
return prevIndex - 1;
});
}
}, [isHovered]);
📝 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.
const prevSpecial = useCallback(() => { | |
if (!isHovered) { // Only change if not hovering | |
setIsTransitioning(true); | |
setCurrentIndex((prevIndex) => { | |
if (prevIndex === 1) { | |
setTimeout(() => { | |
setIsTransitioning(false); | |
setCurrentIndex(infiniteSpecials.length - 2); | |
}, 500); | |
return prevIndex; | |
} | |
return prevIndex - 1; | |
}); | |
} | |
}, [isHovered]); | |
const prevSpecial = useCallback(() => { | |
if (!isHovered) { // Only change if not hovering | |
setIsTransitioning(true); | |
setCurrentIndex((prevIndex) => { | |
if (prevIndex === 1) { | |
setTimeout(() => { | |
setIsTransitioning(false); | |
setCurrentIndex(infiniteSpecials.length - 2); | |
}, 500); | |
return prevIndex; | |
} | |
setTimeout(() => { | |
setIsTransitioning(false); | |
}, 500); | |
return prevIndex - 1; | |
}); | |
} | |
}, [isHovered]); |
} | ||
]; | ||
|
||
const infiniteSpecials = todaysSpecials; |
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
Adjust infiniteSpecials
to enable seamless infinite scrolling
Currently, infiniteSpecials
is a direct reference to todaysSpecials
. To achieve true infinite scrolling behavior, consider modifying infiniteSpecials
to include duplicate items at the start and end of the array. This allows for smooth transitions without abrupt jumps at the edges.
Apply this diff to modify infiniteSpecials
:
-const infiniteSpecials = todaysSpecials;
+const infiniteSpecials = [
+ todaysSpecials[todaysSpecials.length - 1],
+ ...todaysSpecials,
+ todaysSpecials[0]
+];
This change adds the last item of todaysSpecials
to the beginning and the first item to the end, facilitating the infinite loop logic. You'll need to adjust your index handling accordingly in the nextSpecial
and prevSpecial
functions.
Committable suggestion was skipped due to low confidence.
@IkkiOcean lgtm, but can you add auto scroll |
@RamakrushnaBiswal its already has autoscroll. |
6aa8e51
into
RamakrushnaBiswal:main
Description
This PR introduces the
TodaysSpecial
Carousel component, which displays a rotating selection of today's specials in a card format. The component features an automatic scrolling mechanism that pauses when a user hovers over any of the cards, ensuring a user-friendly experience.Changes Made
TodaysSpecial
Component: A new functional component that renders today's specials in a visually appealing card format.Key Features
todaysSpecials
array.Screenshots
special.mp4
Related Issues
Summary by CodeRabbit
New Features
SpecialCard
component for better modularity.Dependencies
lucide-react
for enhanced icon support.react-responsive
for improved responsive design capabilities.