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

fixes down arrow scroll behavior on homepage #2495

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Vipul-Vermaa
Copy link

@Vipul-Vermaa Vipul-Vermaa commented Feb 25, 2025

Closes #2439

Summary by CodeRabbit

  • New Features
    • The homepage now offers smooth scrolling to the "Popular Categories" section when clicking the down arrow, enhancing navigation and streamlining access to key content.

Copy link

vercel bot commented Feb 25, 2025

@Vipul-Vermaa is attempting to deploy a commit to the Vivek Prajapati's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Feb 25, 2025

Walkthrough

The changes modify the DownArrow component and the Home page. The DownArrow now accepts a new prop, scrollToCategories, which is invoked when the arrow image is clicked. In the Home page, a categoriesRef is created and assigned to the "Popular Categories" section, and a scrollToCategories function is defined to perform a smooth scroll to that section. The DownArrow component is updated to receive this function as a prop.

Changes

File(s) Change Summary
src/User/components/DownArrow/downArrow.jsx Updated the component signature to accept a new scrollToCategories prop and added an onClick handler to trigger the passed function when the arrow image is clicked.
src/User/pages/Home/Home.jsx Added a categoriesRef using useRef, defined scrollToCategories to scroll the section into view, passed this function to the DownArrow component, and attached the ref to the section.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DownArrow
    participant Home
    User->>DownArrow: Click on arrow image
    DownArrow->>Home: Call scrollToCategories()
    Home->>Home: Execute categoriesRef.scrollIntoView({ behavior: "smooth" })
Loading

Possibly related PRs

Suggested labels

good first issue, level2, gssoc

Suggested reviewers

  • codervivek5

Poem

I'm just a bunny, hopping through code so bright,
With a scroll and a click, everything feels just right.
DownArrow's now a guide, with a prop that's new,
Smooth scrolling magic—oh, what a view!
Keep on coding and hopping into the light!

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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: 1

🧹 Nitpick comments (1)
src/User/components/DownArrow/downArrow.jsx (1)

6-6: Add prop validation for scrollToCategories

The ESLint error indicates that the scrollToCategories prop is missing validation. Consider adding PropTypes to validate your component props.

import React from "react";
import "../../pages/Home/Home.css";
import Arrow from "../../../assets/arrow.png";
+import PropTypes from "prop-types";
// Make sure to update the path to your actual image location

const DownArrow = ({scrollToCategories}) => {
  return (
    <div className="down-arrow flex justify-center items-center">
      <img
        className="w-12 mt-32 hover:cursor-pointer"
        src={Arrow}
        alt="Down Arrow"
        id="arrow"
        onClick={scrollToCategories}
      />
    </div>
  );
};

+DownArrow.propTypes = {
+  scrollToCategories: PropTypes.func.isRequired
+};

export default DownArrow;
🧰 Tools
🪛 ESLint

[error] 6-6: 'scrollToCategories' is missing in props validation

(react/prop-types)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b6c7313 and 1a96ea3.

📒 Files selected for processing (2)
  • src/User/components/DownArrow/downArrow.jsx (1 hunks)
  • src/User/pages/Home/Home.jsx (3 hunks)
🧰 Additional context used
🪛 ESLint
src/User/components/DownArrow/downArrow.jsx

[error] 6-6: 'scrollToCategories' is missing in props validation

(react/prop-types)

🔇 Additional comments (3)
src/User/pages/Home/Home.jsx (3)

167-169: Implementation looks good

The scrollToCategories function correctly implements smooth scrolling behavior to the categories section. The function is well-named and follows React best practices.


228-228: Correctly passes the scroll function to DownArrow

Properly connects the DownArrow component with the scroll functionality, fulfilling the PR objective to fix down arrow scroll behavior.


233-233: Correctly references the categories section

The ref is properly attached to the section element, allowing the scroll functionality to target the Popular Categories section.

return (
<div className="down-arrow flex justify-center items-center">
<img
className="w-12 mt-32 hover:cursor-pointer"
src={Arrow}
alt="Down Arrow"
id="arrow"
onClick={scrollToCategories}
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

Add fallback for scrollToCategories prop

The onClick handler will cause a runtime error if the scrollToCategories prop is not provided. Consider adding a default fallback.

import React from "react";
import "../../pages/Home/Home.css";
import Arrow from "../../../assets/arrow.png";
import PropTypes from "prop-types";
// Make sure to update the path to your actual image location

const DownArrow = ({scrollToCategories}) => {
  return (
    <div className="down-arrow flex justify-center items-center">
      <img
        className="w-12 mt-32 hover:cursor-pointer"
        src={Arrow}
        alt="Down Arrow"
        id="arrow"
-        onClick={scrollToCategories}
+        onClick={scrollToCategories || (() => {})}
      />
    </div>
  );
};

DownArrow.propTypes = {
  scrollToCategories: PropTypes.func.isRequired
};

export default DownArrow;
📝 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
onClick={scrollToCategories}
import React from "react";
import "../../pages/Home/Home.css";
import Arrow from "../../../assets/arrow.png";
import PropTypes from "prop-types";
// Make sure to update the path to your actual image location
const DownArrow = ({scrollToCategories}) => {
return (
<div className="down-arrow flex justify-center items-center">
<img
className="w-12 mt-32 hover:cursor-pointer"
src={Arrow}
alt="Down Arrow"
id="arrow"
onClick={scrollToCategories || (() => {})}
/>
</div>
);
};
DownArrow.propTypes = {
scrollToCategories: PropTypes.func.isRequired
};
export default DownArrow;

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.

Bug : the arrow down button doesnt have any functionality
1 participant