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

fix: improving scroll to top button elegent and clean design #3637

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Hashir-Akbar
Copy link

@Hashir-Akbar Hashir-Akbar commented Feb 2, 2025

Description

  • Change to <img/> to <Image/> component for performance
  • Improve the design to make it clean and elegant

Related issue(s)
Fixes #3614

image

Summary by CodeRabbit

  • Style
    • Refined the Scroll Button's appearance with updated positioning, border, and shadow effects.
    • Enhanced the scroll image display with consistent sizing for a more polished look.
    • Adjusted the layout of the Community Index Page by rearranging class names for improved CSS application.
    • Removed unused code for a Card component from the Community Index Page.

Copy link
Contributor

coderabbitai bot commented Feb 2, 2025

Walkthrough

This pull request updates the ScrollButton component by replacing the <img> tag with Next.js's <Image /> component. The update includes importing the Image component, specifying width and height attributes, and adjusting the container's styling (positioning, margin removal, added border, and modified shadow) to achieve a more elegant and clean design. Additionally, modifications were made to the layout of the CommunityIndexPage.

Changes

File Summary of changes
components/buttons/ScrollButton.tsx Added import Image from "next/image"; replaced <img> tag with <Image /> (with specified width and height); modified container styling (positioning, border, shadow, and margin removal)
pages/community/index.tsx Rearranged class names in a div element; removed commented-out Card component code.

Assessment against linked issues

Objective Addressed Explanation
Improve scroll-to-top button design & performance (#3614)

Possibly related issues

Possibly related PRs

Suggested labels

ready-to-merge, bounty

Suggested reviewers

  • derberg
  • magicmatatjahu
  • devilkiller-ag
  • akshatnema
  • sambhavgupta0705
  • asyncapi-bot-eve
  • Mayaleeeee
  • anshgoyalevil

Poem

I hopped through lines of code so bright,
Replacing old tags with images that delight.
With borders and shadows, a design so keen,
I crafted a button fit for a dream.
A rabbit’s joy in each refined byte,
Celebrating clean code with a gentle hop in sight!


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 68da685 and 9a88e1d.

📒 Files selected for processing (1)
  • components/buttons/ScrollButton.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/buttons/ScrollButton.tsx
⏰ Context from checks skipped due to timeout of 180000ms (1)
  • GitHub Check: Lighthouse CI

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.

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.

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

Copy link

netlify bot commented Feb 2, 2025

Deploy Preview for asyncapi-website failed.

Built without sensitive environment variables

Name Link
🔨 Latest commit a6a9127
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/679f82fa872fee0008f91fcf

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

🧹 Nitpick comments (1)
components/buttons/ScrollButton.tsx (1)

33-33: Reorder Tailwind classes and consider hover state.

The border and shadow additions create a more elegant design. Consider adding a hover state for better interactivity.

-          className='rounded-full bg-white shadow-darkGunMetal border border-black/25'
+          className='rounded-full border border-black/25 bg-white shadow-darkGunMetal hover:shadow-lg'
🧰 Tools
🪛 GitHub Actions: PR testing - if Node project

[warning] 33-33: Invalid Tailwind CSS classnames order tailwindcss/classnames-order

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8993195 and b920d5c.

⛔ Files ignored due to path filters (1)
  • public/img/loaders/scroll.svg is excluded by !**/*.svg
📒 Files selected for processing (1)
  • components/buttons/ScrollButton.tsx (2 hunks)
🧰 Additional context used
🪛 ESLint
components/buttons/ScrollButton.tsx

[error] 1-2: Run autofix to sort these imports!

(simple-import-sort/imports)


[error] 2-2: Replace "next/image" with 'next/image'

(prettier/prettier)


[error] 2-2: Strings must use singlequote.

(quotes)


[error] 32-34: Replace ⏎··········className='rounded-full·bg-white·shadow-darkGunMetal·border·border-black/25'⏎··········onClick={scrollUp} with ·className='rounded-full·bg-white·shadow-darkGunMetal·border·border-black/25'·onClick={scrollUp}>

(prettier/prettier)


[error] 35-36: Replace ·>⏎·········<Image·src={scrollImage}· with ···<Image·src={scrollImage}

(prettier/prettier)

🪛 GitHub Actions: PR testing - if Node project
components/buttons/ScrollButton.tsx

[error] 1-1: Run autofix to sort these imports! simple-import-sort/imports


[error] 2-2: Replace "next/image" with 'next/image' prettier/prettier


[error] 2-2: Strings must use singlequote. quotes


[warning] 30-30: Invalid Tailwind CSS classnames order tailwindcss/classnames-order


[error] 32-32: Replace ⏎··········className='rounded-full·bg-white·shadow-darkGunMetal·border·border-black/25'⏎··········onClick={scrollUp} with ·className='rounded-full·bg-white·shadow-darkGunMetal·border·border-black/25'·onClick={scrollUp}> prettier/prettier


[warning] 33-33: Invalid Tailwind CSS classnames order tailwindcss/classnames-order


[error] 35-35: Replace ·>⏎·········<Image·src={scrollImage}· with ···<Image·src={scrollImage} prettier/prettier

⏰ Context from checks skipped due to timeout of 180000ms (1)
  • GitHub Check: Lighthouse CI

components/buttons/ScrollButton.tsx Outdated Show resolved Hide resolved
Comment on lines 1 to 2
import React, { useEffect, useState } from 'react';
import Image from "next/image";
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

LGTM! Fix formatting issues.

Good choice using Next.js's Image component for improved performance. However, there are some formatting issues to address:

-import React, { useEffect, useState } from 'react';
-import Image from "next/image";
+import Image from 'next/image';
+import React, { useEffect, useState } from 'react';
📝 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
import React, { useEffect, useState } from 'react';
import Image from "next/image";
import Image from 'next/image';
import React, { useEffect, useState } from 'react';
🧰 Tools
🪛 ESLint

[error] 1-2: Run autofix to sort these imports!

(simple-import-sort/imports)


[error] 2-2: Replace "next/image" with 'next/image'

(prettier/prettier)


[error] 2-2: Strings must use singlequote.

(quotes)

🪛 GitHub Actions: PR testing - if Node project

[error] 1-1: Run autofix to sort these imports! simple-import-sort/imports


[error] 2-2: Replace "next/image" with 'next/image' prettier/prettier


[error] 2-2: Strings must use singlequote. quotes

components/buttons/ScrollButton.tsx Outdated Show resolved Hide resolved
@vishvamsinh28
Copy link
Contributor

@Hashir-Akbar run "npm run lint:fix" to fix lint errors

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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b920d5c and 17bd9fb.

📒 Files selected for processing (2)
  • components/buttons/ScrollButton.tsx (2 hunks)
  • pages/community/index.tsx (1 hunks)
🧰 Additional context used
🪛 ESLint
components/buttons/ScrollButton.tsx

[error] 25-25: Delete ,

(prettier/prettier)


[error] 25-25: Unexpected trailing comma.

(comma-dangle)


[error] 30-30: Replace "fixed·z-40·flex·w-12·bottom-6·right-6·m-0" with 'fixed·z-40·flex·w-12·bottom-6·right-6·m-0'

(prettier/prettier)


[error] 30-30: Unexpected usage of doublequote.

(jsx-quotes)


[error] 32-35: Replace ⏎··········className="rounded-full·border·border-black/25·bg-white·shadow-darkGunMetal"⏎··········onClick={scrollUp}⏎········ with ·className='rounded-full·border·border-black/25·bg-white·shadow-darkGunMetal'·onClick={scrollUp}

(prettier/prettier)


[error] 33-33: Unexpected usage of doublequote.

(jsx-quotes)


[error] 36-41: Replace ⏎············src={scrollImage}⏎············alt="scroll·to·top"⏎············width={120}⏎············height={120}⏎········· with ·src={scrollImage}·alt='scroll·to·top'·width={120}·height={120}

(prettier/prettier)


[error] 38-38: Unexpected usage of doublequote.

(jsx-quotes)

🪛 GitHub Actions: PR testing - if Node project
components/buttons/ScrollButton.tsx

[error] 25-25: Delete ,


[error] 25-25: Unexpected trailing comma.


[warning] 30-30: Invalid Tailwind CSS classnames order


[error] 30-30: Replace "fixed·z-40·flex·w-12·bottom-6·right-6·m-0" with 'fixed·z-40·flex·w-12·bottom-6·right-6·m-0'


[error] 30-30: Unexpected usage of doublequote.


[error] 32-32: Replace ⏎··········className="rounded-full·border·border-black/25·bg-white·shadow-darkGunMetal"⏎··········onClick={scrollUp}⏎········ with ·className='rounded-full·border·border-black/25·bg-white·shadow-darkGunMetal'·onClick={scrollUp}


[error] 33-33: Unexpected usage of doublequote.


[error] 36-36: Replace ⏎············src={scrollImage}⏎············alt="scroll·to·top"⏎············width={120}⏎············height={120}⏎········· with ·src={scrollImage}·alt='scroll·to·top'·width={120}·height={120}


[error] 38-38: Unexpected usage of doublequote.

⏰ Context from checks skipped due to timeout of 180000ms (1)
  • GitHub Check: Lighthouse CI
🔇 Additional comments (4)
components/buttons/ScrollButton.tsx (3)

1-1: LGTM! Good choice using Next.js's Image component.

The addition of the Image component from next/image is a good choice for improved performance and image optimization.


36-41: Adjust image dimensions to match container size.

The image dimensions (120x120) are larger than the container width (w-12 = 48px), which could cause unnecessary scaling and affect performance.

-          <Image
-            src={scrollImage}
-            alt="scroll to top"
-            width={120}
-            height={120}
-          />
+          <Image
+            src={scrollImage}
+            alt='scroll to top'
+            width={48}
+            height={48}
+          />
🧰 Tools
🪛 ESLint

[error] 36-41: Replace ⏎············src={scrollImage}⏎············alt="scroll·to·top"⏎············width={120}⏎············height={120}⏎········· with ·src={scrollImage}·alt='scroll·to·top'·width={120}·height={120}

(prettier/prettier)


[error] 38-38: Unexpected usage of doublequote.

(jsx-quotes)

🪛 GitHub Actions: PR testing - if Node project

[error] 36-36: Replace ⏎············src={scrollImage}⏎············alt="scroll·to·top"⏎············width={120}⏎············height={120}⏎········· with ·src={scrollImage}·alt='scroll·to·top'·width={120}·height={120}


[error] 38-38: Unexpected usage of doublequote.


30-30: ⚠️ Potential issue

Fix formatting issues.

The className needs formatting fixes:

  1. Reorder Tailwind classes according to project conventions
  2. Use single quotes instead of double quotes
-    <div className="fixed z-40 flex w-12 bottom-6 right-6 m-0">
+    <div className='fixed bottom-6 right-6 z-40 flex w-12 m-0'>

Likely invalid or redundant comment.

🧰 Tools
🪛 ESLint

[error] 30-30: Replace "fixed·z-40·flex·w-12·bottom-6·right-6·m-0" with 'fixed·z-40·flex·w-12·bottom-6·right-6·m-0'

(prettier/prettier)


[error] 30-30: Unexpected usage of doublequote.

(jsx-quotes)

🪛 GitHub Actions: PR testing - if Node project

[warning] 30-30: Invalid Tailwind CSS classnames order


[error] 30-30: Replace "fixed·z-40·flex·w-12·bottom-6·right-6·m-0" with 'fixed·z-40·flex·w-12·bottom-6·right-6·m-0'


[error] 30-30: Unexpected usage of doublequote.

pages/community/index.tsx (1)

184-184: LGTM! Improved class name organization.

The reordering of Tailwind classes improves code consistency and readability.

components/buttons/ScrollButton.tsx Outdated Show resolved Hide resolved
Copy link

codecov bot commented Feb 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (ae25e36) to head (a6a9127).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #3637   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           20        20           
  Lines          732       732           
=========================================
  Hits           732       732           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Hashir-Akbar Hashir-Akbar changed the title [FIX] Improving scroll to top button elegent and clean design fix: Improving scroll to top button elegent and clean design Feb 2, 2025
@Hashir-Akbar Hashir-Akbar changed the title fix: Improving scroll to top button elegent and clean design fix: improving scroll to top button elegent and clean design Feb 2, 2025
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.

[FEATURE] Improving scroll to top button elegent and clean design
2 participants