-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Conversation
@@ -50,7 +50,7 @@ export const withProviders = (getStory) => ( | |||
providers={[]} | |||
> | |||
<DocumentationPanelProvider> | |||
<FeatureService> | |||
<FeatureService features={[]}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Broken by #14559
38eeb8f
to
feb3d8b
Compare
There was a problem hiding this 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?
Just checked one more time - now it's okay! |
e8754f9
to
729abd4
Compare
@@ -41,7 +41,7 @@ export const ReleaseStageBadge: React.FC<ReleaseStageBadgeProps> = ({ stage, sma | |||
); | |||
|
|||
return tooltip ? ( | |||
<ToolTip control={badge} cursor="help"> |
There was a problem hiding this comment.
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.
21ab0e2
to
0287dea
Compare
* Add react-tether dependency * Update ToolTip to use react-tether * Add align property to ToolTip
Update tooltip corner to 5px Update package-lock with react-tether
* Add tooltip context * Update tooltip stories to demo with new components
0287dea
to
111e072
Compare
airbyte-webapp/src/views/Connection/ConnectionForm/components/InformationToolTip.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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 }) => ( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
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"> |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
airbyte-webapp/src/views/Connection/ConnectionForm/components/InformationToolTip.tsx
Show resolved
Hide resolved
placement?: Placement; | ||
} | ||
|
||
export type TooltipContext = ToolTipProps; |
There was a problem hiding this comment.
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.
There was a problem hiding this 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
* 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
What
Closes #14581
Updates the Tooltip component to match the design library. Adds the following:
<TooltipLearnMoreButton />
,<TooltipTable />
https://www.loom.com/share/c375493ede804ddb9e28abf06340a0b3
How
InfoIcon
component nested inside theToolTip
component. It is now moved tocomponents/icons
Recommended reading order
Tooltip
TooltipLearnMore
TooltipTable
Tests