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

Improving comprehension epic - glossary tooltip setup #12236

Merged
merged 27 commits into from
Mar 7, 2024

Conversation

pettinarip
Copy link
Member

@pettinarip pettinarip commented Feb 20, 2024

Description

This PR includes the initial setup to support glossary tooltips on pages other than md only pages.

The initial setup includes:

  • new glossary-tooltip.json namespace, which contains short versions of the terms seen in the glossary page
  • the glossary.json namespace is now only used by the glossary page
  • adapt the TooltipLink component to be used in MD pages and other components that use the Translation component

As part of this PR, we are adding new tooltips and term updates to the following pages:


Note: we are going to add more glossary tooltips to other pages in different PRs to make the review easier.

Summary by CodeRabbit

  • New Features

    • Enhanced Glossary components to support additional options for definitions and tooltips.
    • Introduced TooltipLink component to replace MdLink, improving link handling across the application.
    • Added translation capabilities in various pages (dapps, get-eth, layer-2) to support internationalization.
  • Refactor

    • Updated components (GlossaryDefinition, GlossaryTooltip, Translation, Tutorial) to utilize new TooltipLink for better link management.
    • Refined translation utility logic to dynamically include necessary namespaces based on URL paths.
  • Chores

    • Added new constants and props to support the enhanced functionality and internationalization efforts.

@github-actions github-actions bot added content 🖋️ This involves copy additions or edits review needed 👀 translation 🌍 This is related to our Translation Program labels Feb 20, 2024
Copy link

netlify bot commented Feb 20, 2024

Deploy Preview for ethereumorg ready!

Name Link
🔨 Latest commit 0787193
🔍 Latest deploy log https://app.netlify.com/sites/ethereumorg/deploys/65e8801c820765000841ff28
😎 Deploy Preview https://deploy-preview-12236--ethereumorg.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.

@konopkja
Copy link
Contributor

konopkja commented Feb 22, 2024

Screenshot 2024-02-22 at 20 42 11

hi Pablo, noticed few issues with the tooltip:

  1. the background seems transparent (should not be)
  2. it sticks right at the start of the page, the positioning is offf

@konopkja
Copy link
Contributor

Screenshot 2024-02-22 at 20 46 47

positioning and z-index issues

@pettinarip pettinarip changed the title [WIP] Add new glossary tooltips Add new glossary tooltips (/get-eth, /layer-2, /dapps) Feb 26, 2024
@pettinarip pettinarip changed the title Add new glossary tooltips (/get-eth, /layer-2, /dapps) Glossary changes (/get-eth, /layer-2, /dapps) Feb 26, 2024
@pettinarip pettinarip changed the title Glossary changes (/get-eth, /layer-2, /dapps) Glossary tooltip setup + changes (/get-eth, /layer-2, /dapps) Feb 26, 2024
@pettinarip pettinarip marked this pull request as ready for review February 26, 2024 12:23
@pettinarip
Copy link
Member Author

@konopkja nice catches. I'll create separate issues for those in order to keep this PR in the scope.

@corwintines corwintines self-assigned this Feb 28, 2024
@pettinarip pettinarip changed the title Glossary tooltip setup + changes (/get-eth, /layer-2, /dapps) Glossary tooltip setup + usage (/get-eth, /layer-2, /dapps) Mar 4, 2024
@pettinarip pettinarip changed the title Glossary tooltip setup + usage (/get-eth, /layer-2, /dapps) Improving comprehension epic - glossary tooltip setup Mar 4, 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.

image

Not sure if this is in scope here, but noting the opacity makes this a little hard to read (from /get-eth page).

image

I don't think I'm seeing this same opacity issue on all cases though... this is the /dapps page and the text behind it doesn't bleed through like it does above.


Overall working well.. just left a few comments but otherwise think this is close to pulling in.

src/components/Glossary/GlossaryDefinition/index.tsx Outdated Show resolved Hide resolved
src/components/Glossary/GlossaryDefinition/index.tsx Outdated Show resolved Hide resolved
src/components/Translation.tsx Outdated Show resolved Hide resolved
@github-actions github-actions bot added the tooling 🔧 Changes related to tooling of the project label Mar 6, 2024
@pettinarip
Copy link
Member Author

image Not sure if this is in scope here, but noting the opacity makes this a little hard to read (from /get-eth page). image I don't think I'm seeing this same opacity issue on all cases though... this is the /dapps page and the text behind it doesn't bleed through like it does above.

Overall working well.. just left a few comments but otherwise think this is close to pulling in.

Good observation @wackerow. I'll take note of those styles differences since I'm going to tackle them once we finish the migration of the Tooltip component in #10974. That migration should fix most of the style issues but will double-check these ones as well.

Copy link
Contributor

coderabbitai bot commented Mar 6, 2024

Walkthrough

The recent updates focus on enhancing localization and linking capabilities within the application. Key changes include the introduction of the options prop in the GlossaryDefinition component for more flexible translations, a shift towards using TooltipLink for better tooltip integration, and the adoption of the Translation component across various pages for dynamic content rendering. These modifications aim to improve user experience by providing context-sensitive translations and more interactive link elements.

Changes

File(s) Summary of Changes
.../Glossary/GlossaryDefinition/index.tsx, .../constants.ts Added ComponentProps and InlineLink imports, a new constant DEFAULT_GLOSSARY_NS, and an options prop to GlossaryDefinitionProps. Updated GlossaryDefinition for options prop handling.
.../Glossary/GlossaryTooltip/index.tsx Updated GlossaryTooltip to include options prop with { ns: "glossary-tooltip" } for the Tooltip component's content prop.
.../MdComponents.tsx, .../Tutorial.tsx Replaced MdLink with TooltipLink, updating htmlElements and tutorialsComponents objects to point a element to TooltipLink.
.../TooltipLink.tsx Renamed from MdLink and updated to make href prop optional and adjust rendering logic for InlineLink based on href's presence.
.../Translation.tsx Added handling for a transform prop to customize parsing with htmr, merging default and custom transform options.
.../utils/translations.ts Refined namespace determination logic, adjusting conditions for "glossary" and "glossary-tooltip" inclusion.
.../pages/dapps.tsx, .../pages/get-eth.tsx, .../pages/layer-2.tsx Imported ReactNode and Translation where needed, changed description in interfaces to ReactNode, and updated content rendering to use <Translation /> components for dynamic translations. This approach replaces direct text in various sections, enhancing the application's localization and content management flexibility.

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-tests 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 tests 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 tests.
    • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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 6fe80ec and 0787193.
Files ignored due to path filters (5)
  • src/intl/en/glossary-tooltip.json is excluded by: !**/*.json
  • src/intl/en/glossary.json is excluded by: !**/*.json
  • src/intl/en/page-dapps.json is excluded by: !**/*.json
  • src/intl/en/page-get-eth.json is excluded by: !**/*.json
  • src/intl/en/page-layer-2.json is excluded by: !**/*.json
Files selected for processing (11)
  • src/components/Glossary/GlossaryDefinition/index.tsx (2 hunks)
  • src/components/Glossary/GlossaryTooltip/index.tsx (1 hunks)
  • src/components/MdComponents.tsx (2 hunks)
  • src/components/TooltipLink.tsx (3 hunks)
  • src/components/Translation.tsx (1 hunks)
  • src/layouts/Tutorial.tsx (2 hunks)
  • src/lib/constants.ts (1 hunks)
  • src/lib/utils/translations.ts (4 hunks)
  • src/pages/dapps.tsx (6 hunks)
  • src/pages/get-eth.tsx (2 hunks)
  • src/pages/layer-2.tsx (4 hunks)
Additional comments: 21
src/components/Glossary/GlossaryTooltip/index.tsx (1)
  • 16-24: The changes to the GlossaryTooltip component, specifically the addition of the options prop with { ns: "glossary-tooltip" } to the GlossaryDefinition component, are well-implemented. This allows for namespace customization, aligning with the PR's objectives to separate glossary tooltips from the main glossary content. The use of useBreakpointValue from Chakra UI for responsive design is also commendable.
src/components/TooltipLink.tsx (1)
  • 18-31: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [7-41]

The changes to the TooltipLink component, including the renaming from MdLink to TooltipLink, making the href prop optional, and the conditional rendering logic to support glossary tooltips, are well-implemented. The use of a regex pattern to identify glossary links and the clear separation between glossary terms and regular links enhance the component's flexibility and functionality.

src/components/Translation.tsx (1)
  • 1-34: The changes to the Translation component, including the addition of the transform prop and the merging logic for default and custom transform objects, are well-implemented. These improvements enhance the component's flexibility and usability, supporting the seamless integration of glossary tooltips in translated content.
src/components/Glossary/GlossaryDefinition/index.tsx (1)
  • 1-29: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-48]

The changes to the GlossaryDefinition component, including the addition of the options prop for namespace customization and the override of the a mapping to prevent nested tooltips, are well-implemented. The introduction of DEFAULT_GLOSSARY_NS as a constant enhances maintainability. These improvements align with the PR's objectives and enhance the component's functionality and user experience.

src/lib/constants.ts (1)
  • 91-93: The addition of the DEFAULT_GLOSSARY_NS constant for the Glossary Definition Component is a good practice for consistency and maintainability. This change supports the PR's objectives by ensuring consistent namespace usage across the application.
src/components/MdComponents.tsx (1)
  • 27-35: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [32-151]

The changes in MdComponents.tsx, including the removal of MdLink, addition of TooltipLink, and the update to the htmlElements object to use TooltipLink for the a element, are well-implemented. These changes align with the PR's objectives to adapt the TooltipLink component for broader use, including in markdown content, and enable the seamless integration of glossary tooltips in markdown-rendered content.

src/layouts/Tutorial.tsx (1)
  • 35-43: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [40-147]

The changes in Tutorial.tsx, including the removal of MdLink, addition of TooltipLink, and the update to the tutorialsComponents object to use TooltipLink for the a key, are well-implemented. These changes align with the PR's objectives to adapt the TooltipLink component for broader use, including in tutorial content, and enable the seamless integration of glossary tooltips in tutorial-rendered content.

src/lib/utils/translations.ts (2)
  • 175-183: The addition of the "glossary-tooltip" namespace for specific paths (/dapps/, /layer-2/, /wallets/, /get-eth/) is a logical extension to support the PR's objective of enhancing user comprehension with glossary tooltips. This change ensures that the necessary tooltip data is loaded for pages where tooltips are expected to be heavily utilized.
  • 215-215: Including the "glossary-tooltip" namespace for all layouts by default is a strategic decision that aligns with the incremental implementation approach of glossary tooltips across the website. This ensures that the tooltip functionality is readily available as new tooltips are added to various components and pages without requiring additional changes to the namespace requirements.
src/pages/get-eth.tsx (2)
  • 31-31: The import of the Translation component is necessary for the subsequent change where a description is rendered using this component. This aligns with the PR's objective to enhance comprehension by utilizing glossary tooltips and dynamic translations.
  • 297-297: Changing the description rendering to use the Translation component with an ID (page-get-eth:page-get-eth-dex-desc) is a significant improvement. It allows for dynamic translations and the integration of glossary tooltips within the description text. This change enhances the user experience by providing contextual information and definitions for complex terms directly within the content.
src/pages/layer-2.tsx (4)
  • 291-293: The use of <Translation /> components for text content is a good practice for internationalization. This ensures that the content can be easily translated into different languages, enhancing accessibility and user comprehension across diverse audiences.
  • 454-456: The addition of the <Translation /> component for the DYOR (Do Your Own Research) section is consistent with the objective of making the site more accessible to a global audience. It's important to ensure that all dynamic content, such as links and buttons within translated text, is also appropriately handled to maintain functionality across languages.
  • 468-476: The use of <Translation /> components in the "Use Layer 2" section is appropriate. However, it's crucial to verify that all translation keys used here are correctly defined in the corresponding glossary-tooltip.json and other relevant namespaces. This ensures that the translations will load correctly without causing runtime errors or missing content.
Verification successful

The executed scripts have successfully verified the presence of the translation keys page-layer-2:layer-2-contract-accounts and page-layer-2:layer-2-use-layer-2-generalized-1 across multiple language files within the src/intl/ directory. This confirms that the translation keys used in the "Use Layer 2" section are correctly defined in the corresponding translation files for various languages, ensuring that the translations will load correctly without causing runtime errors or missing content.

Based on the provided output, it is evident that the translation keys are well-integrated across a wide range of language-specific JSON files, indicating a comprehensive localization effort for the "Use Layer 2" section. Therefore, the review comment concerning the verification of translation keys in the glossary-tooltip.json and other relevant namespaces has been addressed through the verification process.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that translation keys for the "Use Layer 2" section exist in the glossary-tooltip.json and other relevant namespaces.
# This script is a placeholder and should be replaced with actual verification steps, such as checking the translation files or using a tool to verify the keys.
echo "Verify translation keys in glossary-tooltip.json and other namespaces."

Length of output: 150



Script:

#!/bin/bash
# Search for the translation keys in glossary-tooltip.json
rg "page-layer-2:layer-2-contract-accounts" -t json
rg "page-layer-2:layer-2-use-layer-2-generalized-1" -t json

# Assuming there might be a specific file for the "page-layer-2" namespace, search for it and then search within it
fd "page-layer-2.*\.json" | xargs rg "layer-2-contract-accounts"
fd "page-layer-2.*\.json" | xargs rg "layer-2-use-layer-2-generalized-1"

Length of output: 24652

* 646-648: The addition of the `` component in the FAQ section is a positive step towards making the content more accessible. Similar to previous comments, ensure that all translation keys are correctly defined and that the translations are accurate and contextually appropriate. This is especially important for FAQ content, which often addresses common questions and concerns.
src/pages/dapps.tsx (6)
  • 3-3: The addition of ReactNode from "react" is appropriate for the changes made later in the file, where ReactNode is used as a type for the description property in the Category interface. This change aligns with the PR's objective to enhance comprehension through glossary tooltips, allowing for JSX elements (like <Translation />) to be used in descriptions.
  • 51-51: The import of Translation from "@/components/Translation" is necessary for the implementation of glossary tooltips within the page content. This aligns with the PR's objectives and ensures that translations and glossary tooltips can be dynamically rendered based on the content.
  • 431-431: Changing the description type in the Category interface to ReactNode is a crucial update. This change supports the PR's goal of enhancing user comprehension by allowing glossary tooltips (and potentially other React components) to be included in category descriptions. It's a good practice to use ReactNode for properties that may contain complex JSX content.
  • 611-613: The replacement of text content with the <Translation /> component for the description of a benefit within the CategoryType.FINANCE category is a direct application of the PR's objectives. This change not only supports internationalization but also enables the integration of glossary tooltips within the text, enhancing user comprehension of complex terms. It's important to ensure that all instances where tooltips could enhance understanding are updated similarly.
  • 1346-1346: The use of the <Translation /> component for the subtitle under the "Get Started" section is consistent with the PR's aim to improve comprehension through glossary tooltips. This change ensures that the content is ready for internationalization and can include tooltips as needed. It's a good practice to review all static text content to identify additional opportunities for applying glossary tooltips.
  • 1868-1870: The use of the <Translation /> component for explaining how dApps work further aligns with the PR's objectives. This change ensures that the explanation is accessible to a wider audience through internationalization and can be enhanced with glossary tooltips to clarify complex concepts. Consistency in applying these changes across all educational content is key to maximizing user comprehension.

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.

lgtm! Nice job @pettinarip

@pettinarip pettinarip merged commit cff7a87 into dev Mar 7, 2024
10 checks passed
@pettinarip pettinarip deleted the adding-glossary-tooltips branch March 7, 2024 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content 🖋️ This involves copy additions or edits tooling 🔧 Changes related to tooling of the project translation 🌍 This is related to our Translation Program
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants