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

feat: added scroll indicator #418

Merged

Conversation

Sourabh782
Copy link
Contributor

@Sourabh782 Sourabh782 commented Aug 8, 2024

Related Issue

fixes: #417

Description

Added a Scroll Indicator at the top of site, with matching theme for both dark and light mode. working efficiently as we scroll through the site, also working with the "to the top button" responsively.

Screenshots

Palettegram.-.Social.Media.for.Professionals.-.Google.Chrome.2024-08-08.12-57-01.mp4

Changes in code base:
Added a ProgressBar Component

Summary by CodeRabbit

  • New Features
    • Introduced a ProgressBar component to visually indicate scroll progress on the homepage and the contribution guide page.
  • Style
    • Adjusted the Navbar positioning for improved visual layout by adding a gap from the top of the viewport.

Copy link

vercel bot commented Aug 8, 2024

@Sourabh782 is attempting to deploy a commit to the Sanchit Bajaj's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added wait for reviewers gssoc GSSOC'24 Required Label labels Aug 8, 2024
Copy link
Contributor

coderabbitai bot commented Aug 8, 2024

Walkthrough

The recent changes introduce a ProgressBar component that visually indicates scroll progress on the webpage, enhancing the user interface. This component is integrated into the Home function, positioned prominently above the Navbar. Additionally, a minor adjustment was made to the Navbar's CSS class for improved visual spacing. Overall, these enhancements focus on improving user experience while maintaining existing functionalities.

Changes

Files Change Summary
src/app/page.tsx, src/components/pages/contribute/index.tsx Added ProgressBar component for scroll indication to both Home and Contribute pages.
src/components/ProgressBar/index.tsx Introduced ProgressBar component that displays scroll progress using React hooks and animations.
src/components/core/navbar/index.tsx Changed CSS class from top-0 to top-2 in the <nav> element for better spacing.

Assessment against linked issues

Objective Addressed Explanation
Addition of a dynamic website scroll indicator (417)
Visual positioning adjustments for Navbar (417)

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Great job, @Sourabh782! 🎉 Thank you for submitting your pull request. Your contribution is valuable and we appreciate your efforts to improve our project. Keep being the part of the community!

'We will promptly review your changes and offer feedback. Keep up the excellent work!
Kindly remember to check our Contributing Guidelines'

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, codebase verification and nitpick comments (1)
src/components/ProgressBar/index.tsx (1)

17-17: Remove console log statement.

The console.log(progressWidth) statement is likely for debugging purposes and should be removed in production code.

-        console.log(progressWidth)
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f4405d6 and 73c1a75.

Files selected for processing (3)
  • src/app/page.tsx (2 hunks)
  • src/components/ProgressBar/index.tsx (1 hunks)
  • src/components/core/navbar/index.tsx (1 hunks)
Files skipped from review due to trivial changes (1)
  • src/components/core/navbar/index.tsx
Additional comments not posted (3)
src/app/page.tsx (1)

Line range hint 6-17: Integration of ProgressBar looks good!

The ProgressBar component is correctly imported and integrated into the Home function. Ensure that its placement above the Navbar aligns with the design requirements.

src/components/ProgressBar/index.tsx (2)

4-32: Component structure and styling are appropriate.

The component structure and styling ensure the progress bar is fixed at the top and visually distinct. The use of backdrop-blur-sm and z-10 ensures it remains visible and unobtrusive.


7-24: Verify scroll calculation logic.

The scroll percentage calculation seems correct, but ensure it works as expected across different browsers and screen sizes.

Verification successful

Scroll Calculation Logic Verified

The scroll percentage calculation logic in the handleScroll function appears to be correctly implemented. It calculates the scroll percentage by dividing the current scroll position (scrollY) by the difference between the document height and the window height, then multiplies by 100. This approach should work across different browsers and screen sizes as it dynamically adjusts based on the viewport and document dimensions.

  • File: src/components/ProgressBar/index.tsx
  • Lines: 7-24
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the scroll percentage calculation in the ProgressBar component.

# Test: Ensure the calculation logic is consistent across different browsers and screen sizes.
# Expect: The progress bar accurately reflects the scroll position.
rg --type js -A 10 $'const handleScroll = () => {
  const windowHeight = window.innerHeight;
  const docHeight = document.documentElement.scrollHeight;
  const scrollY = window.scrollY;
  const scrollPercentage = Math.floor((scrollY / (docHeight - windowHeight)) * 100);
}'

Length of output: 783


Script:

#!/bin/bash
# Search for the handleScroll function and include context lines to verify the scroll calculation logic.
rg --type js 'const handleScroll' -A 10

Length of output: 41


Script:

#!/bin/bash
# Search for the handleScroll function in TypeScript files and include context lines to verify the scroll calculation logic.
rg --type ts 'const handleScroll' -A 10

Length of output: 840

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 73c1a75 and 61e9f0d.

Files selected for processing (1)
  • src/components/ProgressBar/index.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/components/ProgressBar/index.tsx

src/app/page.tsx Outdated
@@ -13,6 +14,7 @@ export default async function Home() {

return (
<>
<ProgressBar />
Copy link
Owner

Choose a reason for hiding this comment

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

can't we use the framer motion here? The same is implemented in:
src/components/pages/contribute/index.tsx

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure working on it

@@ -0,0 +1,33 @@
"use client";
Copy link
Owner

Choose a reason for hiding this comment

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

feels a lot of extra work since this feature is already developed

Copy link
Owner

@Sanchitbajaj02 Sanchitbajaj02 left a comment

Choose a reason for hiding this comment

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

Try using the framer motion library and the mentioned component code to implement the logic.

@Sanchitbajaj02 Sanchitbajaj02 added ⭐ enhancement Feature enhancement ✨ goal: improve interface EASY Difficulty Level: Easy level1 10 points and removed wait for reviewers labels Aug 8, 2024
@Sourabh782
Copy link
Contributor Author

Sure working on it 👍

@Sourabh782
Copy link
Contributor Author

@Sanchitbajaj02 hello sir, actually i am having an issue here, as u said to use framer motion library so i can use that, but the
src/app/page.tsx ( Where i m implementing scrollbar ) is showing an error

Screenshot 2024-08-08 184442

to use frammer motion directly i have to use "use client" which generate this error.

but if i implement it using another component ( moving scroll Indicator's code to another component ), it is working fine.

so can i implement it by making a seprate component that uses frammer motion?

@Sanchitbajaj02
Copy link
Owner

@Sanchitbajaj02 hello sir, actually i am having an issue here, as u said to use framer motion library so i can use that, but the
src/app/page.tsx ( Where i m implementing scrollbar ) is showing an error

Screenshot 2024-08-08 184442

to use frammer motion directly i have to use "use client" which generate this error.

but if i implement it using another component ( moving scroll Indicator's code to another component ), it is working fine.

so can i implement it by making a seprate component that uses frammer motion?

What you can do in this case is, modify your progressbar component using framer motion.
This way, that component will be re usable wherever we need it. Then import the same in app/page.tsx

@Sourabh782
Copy link
Contributor Author

Sourabh782 commented Aug 8, 2024

Sure sir, just before making pr can u check it?
image

Also can i replace that peice of frammer motion also from where i took this?
-> src/components/pages/contribute/index.tsx

in this way it would be reusable

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 61e9f0d and e142e03.

Files selected for processing (3)
  • src/app/page.tsx (2 hunks)
  • src/components/ProgressBar/index.tsx (1 hunks)
  • src/components/pages/contribute/index.tsx (2 hunks)
Files skipped from review due to trivial changes (1)
  • src/app/page.tsx
Files skipped from review as they are similar to previous changes (1)
  • src/components/ProgressBar/index.tsx
Additional comments not posted (2)
src/components/pages/contribute/index.tsx (2)

83-83: LGTM! Verify the functionality of the ProgressBar.

The integration of ProgressBar looks good. Ensure that it functions as expected with the scroll animation.

Verification successful

Integration of ProgressBar is verified. The ProgressBar component correctly utilizes the scaleX animation, confirming its intended functionality with the scroll animation.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the functionality of the `ProgressBar` component.

# Test: Check if the `ProgressBar` component utilizes the `scaleX` animation.
rg --type typescript -A 5 'ProgressBar' | grep 'scaleX'

Length of output: 88


Script:

#!/bin/bash
# Description: Verify the functionality of the `ProgressBar` component.

# Test: Check if the `ProgressBar` component utilizes the `scaleX` animation.
rg --type ts -A 5 'ProgressBar' | grep 'scaleX'

Length of output: 130


8-8: Verify the existence of the ProgressBar component.

Ensure that the ProgressBar component is implemented and exported correctly from the specified path.

@Sanchitbajaj02 Sanchitbajaj02 merged commit da5cf81 into Sanchitbajaj02:master Aug 8, 2024
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EASY Difficulty Level: Easy ⭐ enhancement Feature enhancement ✨ goal: improve interface gssoc GSSOC'24 Required Label level1 10 points
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feat: Adding a website scroll indicator on top
2 participants