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

update tooltip component based on new DS #10974

Merged
merged 42 commits into from
Mar 8, 2024

Conversation

amit-ksh
Copy link
Contributor

@amit-ksh amit-ksh commented Aug 21, 2023

Description

Updated the tooltip component according to the new design system using the Chakra Tooltip component.

Related Issue

#9548
Closes #10747

Summary by CodeRabbit

  • New Features

    • Introduced a new Popover component for Chakra UI with customizable styles and configurations.
    • Added a new Tooltip component that displays information on hover, utilizing the Chakra UI Popover.
  • Enhancements

    • Updated various components (DencunBanner, EthPriceCard, WalletMoreInfoCategory, Simulator, StakingStatsBox, GridItem) for improved layout and styling, including better use of Chakra UI components like Box, Icon, and tooltips.
    • Enhanced the Tooltip component's content rendering and configuration options.
  • Code Quality

    • Simplified popover content and styling in Simulator components for cleaner code and better user experience.
    • Adopted forwardRef in Address component for improved component reference handling.
  • Documentation and Examples

    • Added storybook stories for the new Tooltip component to demonstrate usage and configuration.

@gatsby-cloud
Copy link

gatsby-cloud bot commented Aug 21, 2023

✅ ethereum-org-website-dev deploy preview ready

@TylerAPfledderer
Copy link
Contributor

Hey @amit-ksh!

In order for this to be properly reviewed and approved, any component new or existing that is directly affected by the new DS needs to have at least one storybook story (unless otherwise), and following a proposed Storybook structure outline in this figma file. This component is under Molecules / Overlay Content / Tooltips.

Follow the Applying Storybook documentation and let us know if you have any further questions. 😄

I will still help review what you currently have. 👍🏼

Copy link
Contributor

@TylerAPfledderer TylerAPfledderer left a comment

Choose a reason for hiding this comment

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

Only one additional thought.

Copy link
Contributor

@TylerAPfledderer TylerAPfledderer left a comment

Choose a reason for hiding this comment

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

Here are my thoughts so far! 😄

Primarily, I believe the feature branch here should be updated to the latest version of dev and looked over.

There is a new GlossaryTooltip component that is in prod. It is now clear compared to the Figma file that the tooltip component's usage is for specific text in body copy as well as with the info icon that is rendered with content like short statistical information.

I wonder then, if this should be renamed InfoTooltip and reworked so that it only renders the info icon?

If this can be better established, then can comment further on styling issues involving the inner wrapper (the Center component).

cc @pettinarip what do you think?

Copy link
Member

@pettinarip pettinarip left a comment

Choose a reason for hiding this comment

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

Thanks @amit-ksh 💪🏼

While I was reviewing this I noticed that the Tooltip from Chakra might not be the ideal component to use for our tooltips since we use them a bit differently.

  1. we want to put rich content inside the tooltip (like links), not just plain text as it is expected in the Chakra tooltip
  2. we want to keep it open when the user hovers over the tooltip content

That behavior sounds like the Popover is a better fit for this use case. Should be used like this:

<Popover trigger="hover">
  ...
</Popover>

@TylerAPfledderer what do you think of that? or is it possible to control the Tooltip and achieve something like that?

============

Another thing to mention is that we probably don't need to create a new component for this. We probably just need to create a theme file to change the default styles to the ones we want from the DS.

@pettinarip
Copy link
Member

Here are my thoughts so far! 😄

Primarily, I believe the feature branch here should be updated to the latest version of dev and looked over.

There is a new GlossaryTooltip component that is in prod. It is now clear compared to the Figma file that the tooltip component's usage is for specific text in body copy as well as with the info icon that is rendered with content like short statistical information.

I wonder then, if this should be renamed InfoTooltip and reworked so that it only renders the info icon?

If this can be better established, then can comment further on styling issues involving the inner wrapper (the Center component).

cc @pettinarip what do you think?

We can keep the GlossaryTooltip as it is for now.

My idea is to create this "base" tooltip with the base styles and then refactor the GlossaryTooltip accordingly.

Also, this Tooltip should be able to be used anywhere, in any context. I mean, not only on body copy or icons, we should wrap a Card with the tooltip if we would like.

Note: perhaps we should start calling this Popover rather than Tooltip :P

@TylerAPfledderer
Copy link
Contributor

@pettinarip ah, right. Yea the popover is needed to be able to navigate to that rich content via keyboard.

Copy link
Contributor

@TylerAPfledderer TylerAPfledderer left a comment

Choose a reason for hiding this comment

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

One quick item from me at the moment.

Co-authored-by: Tyler Pfledderer <[email protected]>
Copy link
Member

@pettinarip pettinarip left a comment

Choose a reason for hiding this comment

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

Looking good @amit-ksh. I've added a few minor comments.

I think that overall, the new component looks good but is not ready to be used in all the pages we have. We need to tweak a few things from the consumer's side before we can use the new Tooltip.

  • For that reason, lets revert the src/components/Tooltip.tsx removal from this PR.

In a different issue/PR, we will do the transition from the old tooltip to the new tooltip, which is going to involve some style adjustments + more tests across the different pages that are involved.

@TylerAPfledderer TylerAPfledderer mentioned this pull request Sep 13, 2023
amit-ksh and others added 2 commits September 15, 2023 12:26
Co-authored-by: Pablo Pettinari <[email protected]>
Co-authored-by: Pablo Pettinari <[email protected]>
@pettinarip pettinarip assigned pettinarip and unassigned corwintines Mar 4, 2024
@pettinarip
Copy link
Member

pettinarip commented Mar 5, 2024

Reviving this PR.

I've fixed the tooltip theme config to be consistent with all the tooltips we have across the site.

@konopkja this PR fixes the positioning & zindex issues we have with the current custom component.

Pages using the Tooltip:

Copy link
Contributor

coderabbitai bot commented Mar 7, 2024

Walkthrough

The recent updates introduce a redesigned Tooltip component and integrate it across the platform, leveraging the new Popover.ts in Chakra UI for enhanced styling and configuration. Changes streamline the usage of Chakra UI components, specifically transitioning from VStack to Box in various instances for better layout management. The updates also refine the presentation of tooltips and popovers with adjustments to their content, styling, and structural elements, aligning with new design principles.

Changes

File Pattern Change Summary
src/@chakra-ui/components/Popover.ts, src/@chakra-ui/components/components.utils.ts, src/@chakra-ui/components/index.ts Introduced Popover component and integrated it into the Chakra UI component library.
src/components/... (multiple files) Adjusted usage of Chakra UI components, especially replacing VStack with Box and refining tooltip implementations.
src/pages/... (multiple files) Enhanced layout and styling adjustments, including the use of Box for wrapping elements and forwardRef usage improvements.

Assessment against linked issues

Objective Addressed Explanation
Implement new designs for the Tooltip component [#10747] The changes align with the new design requirements for the Tooltip component, as evidenced by the introduction of a new Tooltip component and adjustments across various components for consistent implementation.

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 cff7a87 and a3854e4.
Files selected for processing (15)
  • src/@chakra-ui/components/Popover.ts (1 hunks)
  • src/@chakra-ui/components/components.utils.ts (2 hunks)
  • src/@chakra-ui/components/index.ts (2 hunks)
  • src/components/DencunBanner.tsx (2 hunks)
  • src/components/EthPriceCard.tsx (1 hunks)
  • src/components/FindWallet/WalletTable/WalletMoreInfoCategory.tsx (1 hunks)
  • src/components/Simulator/MoreInfoPopover.tsx (1 hunks)
  • src/components/Simulator/NotificationPopover.tsx (1 hunks)
  • src/components/Staking/StakingStatsBox.tsx (5 hunks)
  • src/components/StatsBoxGrid/GridItem.tsx (3 hunks)
  • src/components/Tooltip/Tooltip.stories.tsx (1 hunks)
  • src/components/Tooltip/index.tsx (1 hunks)
  • src/pages/stablecoins.tsx (3 hunks)
  • src/pages/staking/deposit-contract.tsx (3 hunks)
  • src/pages/what-is-ethereum.tsx (6 hunks)
Additional comments: 22
src/components/Tooltip/index.tsx (2)
  • 11-13: The IProps interface extends PopoverProps and adds a content prop for the tooltip content and an optional children prop. This is a clear and concise way to define the component's expected props, ensuring that all necessary Chakra UI PopoverProps can be passed through while also specifying the additional props required by this custom Tooltip component.
  • 16-36: The Tooltip component is correctly implemented using Chakra UI's Popover components. It sets default properties such as placement, trigger, and strategy to ensure consistent behavior across uses. The use of rest parameters (...rest) to pass any additional PopoverProps is a good practice, allowing for flexibility in the component's usage. However, consider adding PropTypes or TypeScript definitions for better type safety and documentation, especially for projects that heavily rely on component libraries.
src/components/Simulator/NotificationPopover.tsx (3)
  • 29-29: The PopoverContent component's padding and maximum width have been adjusted. This simplification aligns with the aim to standardize the component's appearance. However, ensure that these changes do not adversely affect the layout or readability in different contexts where the NotificationPopover might be used.
  • 31-31: Adjusting the PopoverHeader's margin and padding is a good practice for maintaining consistency in the component's design. It's important to verify that these changes harmonize with the overall design system and do not introduce any unexpected layout shifts.
  • 36-36: Simplifying the PopoverBody padding to 0 might affect the content's readability and appearance. Consider testing this change across different screen sizes and content types to ensure it maintains a good user experience.
src/components/DencunBanner.tsx (2)
  • 9-9: The import statement correctly switches from using a Tooltip component from @chakra-ui/react to the newly defined local Tooltip component. This change is necessary to align with the PR's objective of updating the Tooltip component according to the new design system.
  • 21-24: The updated usage of the Tooltip component with a content prop instead of label is in line with the new component's API. Wrapping the upgradeDate with a span element inside the Tooltip trigger is a good practice for accessibility and semantic HTML. Ensure that the aria-label property, which was previously used, is appropriately handled or migrated to the new implementation to maintain accessibility standards.
src/components/Tooltip/Tooltip.stories.tsx (1)
  • 51-51: Given the existing comments and responses, it appears that the request for a new story showcasing rich content usage has been addressed. This is a good practice for demonstrating the component's capabilities and ensuring it meets the design requirements.
src/@chakra-ui/components/index.ts (1)
  • 22-22: Adding the Popover component to the list of exported components from @chakra-ui/components is a necessary step to ensure it can be used throughout the project. This change aligns with the PR's objectives of updating the Tooltip component and leveraging Chakra UI components more extensively.
src/components/EthPriceCard.tsx (1)
  • 144-146: The modification to wrap the tooltip icon in a Box component is a good practice for applying additional styling or layout control in Chakra UI. Ensure that the visual outcome aligns with the new design system's requirements.
src/components/StatsBoxGrid/GridItem.tsx (1)
  • 35-57: The layout adjustments using Box and HStack components, along with the modifications to the tooltip icon's styling, are well-thought-out changes that likely aim to enhance the component's usability and visual appeal. Ensure these changes are consistent with the new design system and consider accessibility implications.
src/pages/staking/deposit-contract.tsx (1)
  • 135-143: > 📝 NOTE

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

The use of forwardRef in the Address component is correctly implemented and enhances the component's flexibility by allowing direct interaction with the DOM element. Ensure that the necessity and intended use cases for this feature are documented to avoid confusion or misuse.

src/pages/stablecoins.tsx (4)
  • 239-244: The change from <div> to <Box> for tooltipContent aligns well with the Chakra UI framework's approach, ensuring consistency in component usage throughout the project. Good job on maintaining design system consistency.
  • 239-239: Adjusting the indentation for {t("common:data-provided-by")} improves code readability and adheres to consistent formatting practices. It's important to maintain such standards for code quality.
  • 605-605: Correcting the indentation for {t("page-stablecoins-algorithmic-disclaimer")} is a good practice for maintaining code quality and readability. Consistent formatting is key in collaborative projects.
  • 734-734: Removing extra whitespace before <Flex> contributes to a cleaner and more readable codebase. It's great to see attention to detail in maintaining clean code practices.
src/pages/what-is-ethereum.tsx (6)
  • 482-484: The change to wrap the <Icon> component in a <Box> with as="span" and verticalAlign="middle" is a good improvement. It enhances both the semantic structure and the visual alignment of the icon with adjacent text.
  • 503-505: This instance of wrapping the <Icon> component in a <Box> with as="span" and verticalAlign="middle" maintains consistency and improves the page's semantic structure and visual alignment. Good job on applying these improvements consistently.
  • 524-526: Consistent with previous instances, wrapping the <Icon> component in a <Box> with as="span" and verticalAlign="middle" here as well ensures uniformity and enhances the page's semantic markup and visual presentation.
  • 544-546: Again, wrapping the <Icon> component in a <Box> with as="span" and verticalAlign="middle" is applied consistently, enhancing the semantic structure and alignment of the icon. This consistent application across the page is commendable.
  • 566-568: The consistent application of wrapping the <Icon> component in a <Box> with as="span" and verticalAlign="middle" here as well further solidifies the improvements in semantic structure and visual alignment across the page.
  • 590-592: Wrapping the <Icon> component in a <Box> with as="span" and verticalAlign="middle" for this final instance maintains the high standard of consistency and quality seen throughout the page. Excellent attention to detail in enhancing both the semantic and visual aspects.

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 a3854e4 and ffa36de.
Files selected for processing (7)
  • src/@chakra-ui/components/Popover.ts (1 hunks)
  • src/components/Staking/StakingStatsBox.tsx (5 hunks)
  • src/components/StatsBoxGrid/GridItem.tsx (3 hunks)
  • src/components/Tooltip/index.tsx (1 hunks)
  • src/pages/stablecoins.tsx (2 hunks)
  • src/pages/staking/deposit-contract.tsx (3 hunks)
  • src/pages/what-is-ethereum.tsx (6 hunks)
Files skipped from review as they are similar to previous changes (7)
  • src/@chakra-ui/components/Popover.ts
  • src/components/Staking/StakingStatsBox.tsx
  • src/components/StatsBoxGrid/GridItem.tsx
  • src/components/Tooltip/index.tsx
  • src/pages/stablecoins.tsx
  • src/pages/staking/deposit-contract.tsx
  • src/pages/what-is-ethereum.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 ffa36de and 8bf4efc.
Files selected for processing (2)
  • src/@chakra-ui/components/Popover.ts (1 hunks)
  • src/components/FindWallet/WalletTable/WalletMoreInfoCategory.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • src/@chakra-ui/components/Popover.ts
  • src/components/FindWallet/WalletTable/WalletMoreInfoCategory.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: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 8bf4efc and db12afd.
Files selected for processing (1)
  • src/components/Glossary/GlossaryTooltip/index.tsx (2 hunks)

Copy link
Member

@pettinarip pettinarip left a comment

Choose a reason for hiding this comment

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

🚀

@pettinarip pettinarip merged commit afb697f into ethereum:dev Mar 8, 2024
10 checks passed
Copy link

gitpoap-bot bot commented Mar 8, 2024

Congrats, your important contribution to this open-source project has earned you a GitPOAP!

Be sure to join the Ethereum.org discord if you are interested in contributing further to the project or have any questions for the team.

GitPOAP: 2024 Ethereum.org Contributor:

GitPOAP: 2024 Ethereum.org Contributor GitPOAP Badge

Head to gitpoap.io & connect your GitHub account to mint!

Learn more about GitPOAPs here.

@konopkja
Copy link
Contributor

konopkja commented Mar 11, 2024

@pettinarip i noticed in the PR that on find-wallet page some tooltips adopt wrong styles. What should we do with this?
Screenshot 2024-03-11 at 15 12 28

@pettinarip
Copy link
Member

@pettinarip i noticed in the PR that on find-wallet page some tooltips adopt wrong styles. What should we do with this?

I see. I'll create a fix for this soon 👍🏼

This was referenced Mar 13, 2024
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tooltip
5 participants