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: fixed links to specific category in tools section #2190

Closed
wants to merge 12 commits into from

Conversation

aryanas159
Copy link
Contributor

Description

  • Added useEffect to scroll to the particular div, if provided.
Untitled.video.-.Made.with.Clipchamp.4.mp4

Related issue(s)

Fixes #2181

@netlify
Copy link

netlify bot commented Oct 1, 2023

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit d08cb6e
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/6572c805d277270008586777
😎 Deploy Preview https://deploy-preview-2190--asyncapi-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions
Copy link

github-actions bot commented Oct 1, 2023

⚡️ Lighthouse report for the changes in this PR:

Category Score
🔴 Performance 24
🟢 Accessibility 98
🟢 Best practices 100
🟢 SEO 100
🔴 PWA 30

Lighthouse ran on https://deploy-preview-2190--asyncapi-website.netlify.app/

@aryanas159 aryanas159 changed the title fix: issue #2181 Links in tools section to specific category do not work fix: issue #2181 Links in tools section to specific category do not work Oct 1, 2023
@akshatnema akshatnema changed the title fix: issue #2181 Links in tools section to specific category do not work fix: fixed links to specific category in tools section Oct 20, 2023
element.scrollIntoView({ behavior: 'smooth', block: "nearest", inline: "nearest" })
}
}, 1000)
}, [])
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
}, [])
}, [])

Kindly add a spacing to make it more readable inside codebase (since they are 2 different sections of code).

@@ -6,7 +6,7 @@ export default function toolsList({ toolsData }) {
<div className="" data-testid="ToolsList-main" >
{Object.keys(toolsData).map((categoryName, index) => {
if(toolsData[categoryName].toolsList.length > 0) return (
<div className='my-8' key={index} id={categoryName}>
<div className='my-8' key={index} id={categoryName} style={{scrollMargin: "100px"}}>
Copy link
Member

Choose a reason for hiding this comment

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

You can't use inline styles to add styling inside div. Kindly use tailwind utility classes to add the CSS.

@@ -26,6 +26,7 @@ async function buildNewsroomVideos() {
const videoData = JSON.stringify(videoDataItems, null, ' ');
console.log('The following are the Newsroom Youtube videos: ', videoData)


Copy link
Member

Choose a reason for hiding this comment

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

Suggested change

Kindly remove non-relevant changes from your PR.

@asyncapi-bot
Copy link
Contributor

asyncapi-bot commented Dec 7, 2023

⚡️ Lighthouse report for the changes in this PR:

Category Score
🔴 Performance 39
🟢 Accessibility 98
🟢 Best practices 92
🟢 SEO 100
🔴 PWA 33

Lighthouse ran on https://deploy-preview-2190--asyncapi-website.netlify.app/

setTimeout(() => {
const path = router?.asPath
const id = path?.slice(path?.indexOf("#") + 1).replace("%20", " ")
const element = document.getElementById(id)
Copy link
Member

Choose a reason for hiding this comment

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

Instead of using id attribute, can't we use ref here to add the behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can think about this, but the "Jump to Category" dropdown already uses the "id" of each div to scroll to, so wouldn't it be better to use the same strategy for initial scrolling as well?

Copy link
Member

Choose a reason for hiding this comment

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

We usually access the DOM elements directly in react. React has it's own virtual DOM feature which enables better performance on the website. That's why I asked to use ref in this case. We used id just to reference the category and link it in dropdown.

@@ -6,7 +6,7 @@ export default function toolsList({ toolsData }) {
<div className="" data-testid="ToolsList-main" >
{Object.keys(toolsData).map((categoryName, index) => {
if(toolsData[categoryName].toolsList.length > 0) return (
<div className='my-8' key={index} id={categoryName}>
<div className='my-8 scroll-m-[100px]' key={index} id={categoryName}>
Copy link
Member

Choose a reason for hiding this comment

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

Don't use units in px. Instead use rem, em or tailwind utility classes to add a scroll margin. Using pixels will impact responsiveness of the website.

@sambhavgupta0705
Copy link
Member

@aryanas159 are you still working on it

@aryanas159
Copy link
Contributor Author

@sambhavgupta0705 No I'm not, I put a reply above for the changes requested, but I don't think they were reviewed.

Copy link
Member

Choose a reason for hiding this comment

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

Why there are changes in this file?

@aryanas159 aryanas159 closed this Feb 5, 2024
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.

Links in tools section to specific category do not work
4 participants