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 to match design library #14816

Merged
merged 17 commits into from
Aug 18, 2022

Conversation

edmundito
Copy link
Contributor

@edmundito edmundito commented Jul 18, 2022

What

Closes #14581

Updates the Tooltip component to match the design library. Adds the following:

  • Light and Dark Mode
  • Align to top, right, bottom, left side of the parent element
  • Add components to match design layout: <TooltipLearnMoreButton />, <TooltipTable />

https://www.loom.com/share/c375493ede804ddb9e28abf06340a0b3

How

  • The component now uses floating-ui to set the tooltip position. There is a specific timing effect to ensure that the user can hover over the tooltip to click on links in the tooltip.
  • The component is now migrated to SCSS
  • There was an InfoIcon component nested inside the ToolTip component. It is now moved to components/icons
  • Added storybook for testing

Recommended reading order

  1. Tooltip
  2. TooltipLearnMore
  3. TooltipTable
  4. Rest of code

Tests

  • Tested every component that used the Tooltip component to verify that it looks good.

@github-actions github-actions bot added the area/platform issues related to the platform label Jul 18, 2022
@@ -50,7 +50,7 @@ export const withProviders = (getStory) => (
providers={[]}
>
<DocumentationPanelProvider>
<FeatureService>
<FeatureService features={[]}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Broken by #14559

@edmundito edmundito changed the title Update Tooltip component to match design library 🪟 🎨 Update Tooltip component to match design library Jul 18, 2022
@edmundito edmundito force-pushed the edmundito/update-tooltip branch 2 times, most recently from 38eeb8f to feb3d8b Compare July 22, 2022 21:51
@edmundito edmundito marked this pull request as ready for review July 22, 2022 22:36
@edmundito edmundito requested a review from a team as a code owner July 22, 2022 22:36
Copy link
Contributor

@dizel852 dizel852 left a comment

Choose a reason for hiding this comment

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

Wasn't able to test locally - storybook crashes.
@edmundito how have you managed to run storybook?

image

@dizel852
Copy link
Contributor

dizel852 commented Aug 2, 2022

Wasn't able to test locally - storybook crashes. @edmundito how have you managed to run storybook?

image

Just checked one more time - now it's okay!

@edmundito edmundito force-pushed the edmundito/update-tooltip branch 2 times, most recently from e8754f9 to 729abd4 Compare August 3, 2022 19:43
@edmundito edmundito requested review from dizel852 and timroes August 3, 2022 19:45
@@ -41,7 +41,7 @@ export const ReleaseStageBadge: React.FC<ReleaseStageBadgeProps> = ({ stage, sma
);

return tooltip ? (
<ToolTip control={badge} cursor="help">
Copy link
Contributor Author

@edmundito edmundito Aug 4, 2022

Choose a reason for hiding this comment

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

While reviewing the design with @Upmitt, it was decided that it didn't make sense to show the help cursor here.

@edmundito edmundito force-pushed the edmundito/update-tooltip branch from 21ab0e2 to 0287dea Compare August 4, 2022 18:15
@edmundito edmundito requested a review from a team August 9, 2022 13:36
@edmundito edmundito force-pushed the edmundito/update-tooltip branch from 0287dea to 111e072 Compare August 10, 2022 16:32
Copy link
Contributor

@lmossman lmossman left a comment

Choose a reason for hiding this comment

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

Just had a couple questions when reading through this!

url: string;
}

export const TooltipLearnMoreLink: React.VFC<TooltipLearnMoreLinkProps> = ({ url }) => (
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, why did you use React.VFC<> here, but React.FC<> in the ToolTip component?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

VFC (Void FunctionComponent) is a type of component that does not allow children to be passed through it. It's something I discovered recently while working on this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see, and we don't want this component to have any children because it is just a simple div with a link

}

export const TooltipTable: React.VFC<TooltipTableProps> = ({ rows }) => {
const { theme } = useTooltipContext();
Copy link
Contributor

Choose a reason for hiding this comment

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

For my own learning, could you briefly explain why you chose to use a context here? Is this because the theme prop could not be passed directly to TooltipTable, because that sub-component is not always present?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did this in order to understand the context of the tooltip without having to pass the props twice. Otherwise in the component that implements you you'd have to pass the same theme:

<Tooltip theme="light">
  <TooltipTable theme="light" />
</Tooltip>

// Nothing stopping you from doing:
<Tooltip theme="light">
  <TooltipTable /> // If you don't pass the theme and have no context, the theme of the table will be "dark"
</Tooltip>

Copy link
Contributor

@lmossman lmossman Aug 10, 2022

Choose a reason for hiding this comment

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

Ah okay, so this is basically forcing the TooltipTable to match the same theme as its parent Tooltip through the use of context, removing that burden from the developer who adds the TooltipTable component somewhere. That is cool, thanks for explaining!


export const TooltipLearnMoreLink: React.VFC<TooltipLearnMoreLinkProps> = ({ url }) => (
<div className={styles.container}>
<a href={url} target="_blank" rel="noreferrer">
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably not worth the effort, nor would this be the place, but I'd love to have a component that would always tack on target="_blank" rel="noreferrer"
But remembering to use it would likely be more obnoxious than just adding this since the linter yells about it.
If we ever wanted click tracking for analytics we could create a TrackingLink component or something and put that in there. 🤷


import { TooltipContext } from "./types";

export const tooltipContext = createContext<TooltipContext | null>(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

We use both camelCase and PascalCase for context's. We should decide one way or the other just for consistency.
My argument for PascalCase is since it's used as part of JSX and looks like a component, it should match that kind of usage.

placement?: Placement;
}

export type TooltipContext = ToolTipProps;
Copy link
Contributor

Choose a reason for hiding this comment

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

Feels odd to look at, but I get it.

Copy link
Contributor

@dizel852 dizel852 left a comment

Choose a reason for hiding this comment

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

Overall - LGTM.
Tested locally using storybook

@edmundito edmundito merged commit e380c26 into master Aug 18, 2022
@edmundito edmundito deleted the edmundito/update-tooltip branch August 18, 2022 18:05
rodireich pushed a commit that referenced this pull request Aug 25, 2022
* Add ToolTip storybook

* Update ToolTip to scss

* gitignore storybook-static dir

* Move InfoIcon from ToolTip to icons and remove duplicate

* Fix disabled class name in ToolTip

* Update ToolTip colors and spacing to match updated design and add light mode

* Update ToolTip to show from any side perfectly centered

* Add react-tether dependency
* Update ToolTip to use react-tether
* Add align property to ToolTip

* Add link colors to tooltip links and update storybook

* Fix font-size in Tooltip

* Add minor tweaks to Tooltip component

* Remove "help" cursor from state badge
Update tooltip corner to 5px
Update package-lock with react-tether

* Tooltip mode -> Tooltip theme

* Add tooltip helper components for learn more url and table

* Add tooltip context
* Update tooltip stories to demo with new components

* REname tooltip index from tsx to ts

* Update tooltip to use floating-ui instead of react-tether

* Move z-index values to own z-indices file

* Update InformationTooltip to use regular tooltip style
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/frontend Related to the Airbyte webapp area/platform issues related to the platform ui/components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update ToolTip component to match design library
5 participants