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

Add auto-linked headers on glossary page [Fixes #12393] #12455

Merged
merged 10 commits into from
May 24, 2024

Conversation

checkomkar
Copy link
Contributor

@checkomkar checkomkar commented Mar 14, 2024

Fixes [#12393]

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Enhanced the Glossary Definition component to display a link icon on hover, improving user interactivity and visual feedback.
    • Added a link icon to the Glossary Definition component for better user experience.

Copy link
Contributor

coderabbitai bot commented Mar 14, 2024

Walkthrough

The update to the GlossaryDefinition component enriches user interaction by integrating a link icon, which becomes visible when a user hovers over a glossary term. This enhancement not only adds a visual indicator for clickable terms but also involves incorporating state management to control the visibility of the link icon, alongside adjustments in the component's rendering logic to accommodate this new feature.

Changes

File Path Change Summary
src/components/Glossary/GlossaryDefinition/index.tsx Enhanced to show a link icon on hover over the term, involving state management for icon visibility and updates in rendering logic.

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:

Note: Auto-reply has been disabled for this repository by the repository owner. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

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

CodeRabbit Configration 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

netlify bot commented Mar 14, 2024

Deploy Preview for ethereumorg ready!

Name Link
🔨 Latest commit ca5b7d3
🔍 Latest deploy log https://app.netlify.com/sites/ethereumorg/deploys/66511dfb08ddb00008b02c90
😎 Deploy Preview https://deploy-preview-12455--ethereumorg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
7 paths audited
Performance: 33 (🔴 down 5 from production)
Accessibility: 92 (no change from production)
Best Practices: 89 (🔴 down 3 from production)
SEO: 93 (no change from production)
PWA: -
View the detailed breakdown and full score reports

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

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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b1d4f64 and 3be6bc4.
Files selected for processing (1)
  • src/components/Glossary/GlossaryDefinition/index.tsx (2 hunks)
Additional comments: 3
src/components/Glossary/GlossaryDefinition/index.tsx (3)
  • 1-3: The imports have been updated to include useState from "react", and additional components from "@chakra-ui/react" and "react-icons/vsc". Ensure that these new dependencies are properly documented and their versions are compatible with the project's current setup.
  • 27-27: Introduced state management using useState to control the visibility of the link icon. This is a straightforward and effective approach for handling hover interactions. However, consider adding a brief comment explaining the purpose of showLink state for future maintainability.
  • 35-47: The styling for the link and link icon is defined inline. While this is acceptable for small components, consider moving these styles to a separate file or using a theming approach if the project's scale increases. This would improve maintainability and consistency across the project.

src/components/Glossary/GlossaryDefinition/index.tsx Outdated Show resolved Hide resolved
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 3be6bc4 and 1364314.
Files selected for processing (1)
  • src/components/Glossary/GlossaryDefinition/index.tsx (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/components/Glossary/GlossaryDefinition/index.tsx

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 1364314 and cf2e80d.
Files selected for processing (1)
  • src/components/Glossary/GlossaryDefinition/index.tsx (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/components/Glossary/GlossaryDefinition/index.tsx

@wackerow wackerow changed the title Fix [#12393]: Missing auto-linked headers on glossary page Add auto-linked headers on glossary page [Fixes #12393] Mar 19, 2024
Copy link
Member

@wackerow wackerow left a comment

Choose a reason for hiding this comment

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

Hey @checkomkar, thanks for this!

Couple things... we seem to be recreating a lot of logic and styling that has already been built elsewhere...

  • We should use the same icon as the others (CiLink from react-icons/ci), and the size should match
  • The word itself should not be clickable... the link icon should appear while hovering the word, but only the icon should contain the link itself
  • Needs a scrollMarginTop so the header isn't hidden by the nav bar when navigating to it

This is all implemented inside MdComponents for the standard markdown headers, ie Heading3. These utilize a reusable IdAnchor component (also in that file) that handles the link and icon:

image

This component is then placed inside a header, along with {...commonHeadingProps(id)} to get the props needed for styling, and to assign the appropriate ID.

I'd ask that we take another look here and try to simplify, reusing components where possible and removing the redundant logic. Let us know if you're having issues!

(Last note, the files need to be linted/formatted before they will build correctly... in particular, the imports at top need to follow a certain order... VS Code formatter can do this automatically, but if you're not sure how to set this up we can handle fixing that up when ready)

@checkomkar
Copy link
Contributor Author

Hey @checkomkar, thanks for this!

Couple things... we seem to be recreating a lot of logic and styling that has already been built elsewhere...

  • We should use the same icon as the others (CiLink from react-icons/ci), and the size should match
  • The word itself should not be clickable... the link icon should appear while hovering the word, but only the icon should contain the link itself
  • Needs a scrollMarginTop so the header isn't hidden by the nav bar when navigating to it

This is all implemented inside MdComponents for the standard markdown headers, ie Heading3. These utilize a reusable IdAnchor component (also in that file) that handles the link and icon:

image This component is then placed inside a header, along with `{...commonHeadingProps(id)}` to get the props needed for styling, and to assign the appropriate ID.

I'd ask that we take another look here and try to simplify, reusing components where possible and removing the redundant logic. Let us know if you're having issues!

(Last note, the files need to be linted/formatted before they will build correctly... in particular, the imports at top need to follow a certain order... VS Code formatter can do this automatically, but if you're not sure how to set this up we can handle fixing that up when ready)

Thank you @wackerow for the detailed review. Will make the changes as suggested. Also with regards to linting, I tried through VS code somehow it's not working, the import order doesn't seem to sort. Is there any extension that I am supposed to use or any lint command?

@wackerow
Copy link
Member

Thank you @wackerow for the detailed review. Will make the changes as suggested. Also with regards to linting, I tried through VS code somehow it's not working, the import order doesn't seem to sort. Is there any extension that I am supposed to use or any lint command?

@checkomkar Try yarn lint:fix to handle this... If that doesn't work, try Cmd/Ctrl+Shift+P to open the command palette and type/select "ESLint: Fix all auto-fixable Problems"... this should apply the same rules.

@wackerow wackerow added Status: Blocked 🛑 This is blocked dev required This requires developer resources labels Mar 20, 2024
@checkomkar
Copy link
Contributor Author

Hey @checkomkar, thanks for this!

Couple things... we seem to be recreating a lot of logic and styling that has already been built elsewhere...

  • We should use the same icon as the others (CiLink from react-icons/ci), and the size should match
  • The word itself should not be clickable... the link icon should appear while hovering the word, but only the icon should contain the link itself
  • Needs a scrollMarginTop so the header isn't hidden by the nav bar when navigating to it

This is all implemented inside MdComponents for the standard markdown headers, ie Heading3. These utilize a reusable IdAnchor component (also in that file) that handles the link and icon:

image This component is then placed inside a header, along with `{...commonHeadingProps(id)}` to get the props needed for styling, and to assign the appropriate ID.

I'd ask that we take another look here and try to simplify, reusing components where possible and removing the redundant logic. Let us know if you're having issues!

(Last note, the files need to be linted/formatted before they will build correctly... in particular, the imports at top need to follow a certain order... VS Code formatter can do this automatically, but if you're not sure how to set this up we can handle fixing that up when ready)

Hey @wackerow I tried importing and reusing the components as you suggested, but it was causing cyclic import error so I just copied the IdAnchor into the GlossaryDefinition index file and this is working. Please let me know if I can better this. Thanks.

@wackerow
Copy link
Member

wackerow commented Apr 1, 2024

Hey @wackerow I tried importing and reusing the components as you suggested, but it was causing cyclic import error so I just copied the IdAnchor into the GlossaryDefinition index file and this is working. Please let me know if I can better this. Thanks.

@checkomkar To use the existing IdAnchor component, we just need to export it where it's defined by adding export before const IdAnchor ... inside MdComponents.tsx, ie:

export const IdAnchor = ({ id }: { id?: string }) => {

Then we can import this inside GlossaryDefinition/index.tsx with:

import { IdAnchor } from "@/components/MdComponents"

We can then remove the entire IdAnchor function from this file, and remove the unused imports (CiLink, Icon and Link). Would run yarn lint:fix again after this.

@wackerow
Copy link
Member

wackerow commented Apr 8, 2024

Just checking in, @checkomkar let me know if you want a hand getting this over the line

@checkomkar
Copy link
Contributor Author

Hey @wackerow I tried importing and reusing the components as you suggested, but it was causing cyclic import error so I just copied the IdAnchor into the GlossaryDefinition index file and this is working. Please let me know if I can better this. Thanks.

@checkomkar To use the existing IdAnchor component, we just need to export it where it's defined by adding export before const IdAnchor ... inside MdComponents.tsx, ie:

export const IdAnchor = ({ id }: { id?: string }) => {

Then we can import this inside GlossaryDefinition/index.tsx with:

import { IdAnchor } from "@/components/MdComponents"

We can then remove the entire IdAnchor function from this file, and remove the unused imports (CiLink, Icon and Link). Would run yarn lint:fix again after this.

I get this cyclic import error whenever I am trying to import IdAnchor in GlossaryDefinition/index.tsx, not sure how to resolve this.

image

@wackerow
Copy link
Member

wackerow commented Apr 10, 2024

@checkomkar
Okay I think I know what's going on, two things...
1- Make sure you added export before const IdAnchor on line 66 inside MdComponents.tsx
2- Make sure you're using a named import and not a default:

// This:
import { IdAnchor } from "@/components/MdComponents"
// Not this:
import IdAnchor from "@/components/MdComponents"

That file had a default export as well at the bottom, which is an object with all the markdown components, and would be assigned to IdAnchor with the "Not this" approach above. You'd get a circular error in that case because that object also has other components that do form a circular reference with that TooltipLink link being imported into GlossaryDefinition.

You should be able to use the { IdAnchor } approach though after adding the keyword export before that function declaration.

@wackerow
Copy link
Member

wackerow commented May 7, 2024

Checking in... Any luck @checkomkar? Happy to try and get this over the line if you're not available

Copy link
Member

@wackerow wackerow left a comment

Choose a reason for hiding this comment

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

Just extracted the IdAnchor component as it's own file component to avoid any circular reference issues... looks good! Pulling in, thanks a lot @checkomkar!

@wackerow wackerow merged commit f4a2101 into ethereum:dev May 24, 2024
5 of 7 checks passed
@wackerow
Copy link
Member

@all-contributors please add @checkomkar for code

Copy link
Contributor

@wackerow

I've put up a pull request to add @checkomkar! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev required This requires developer resources Status: Blocked 🛑 This is blocked
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants