-
Notifications
You must be signed in to change notification settings - Fork 452
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: extract InfoTooltip to its own component
Change-Id: I394a3fe6a0eeef8cb579d61b710fe6e217fea015 GitOrigin-RevId: 3fca1dd90d790ac002345262eda7a1e2e19108e4
- Loading branch information
1 parent
2a10fa0
commit 77eecc5
Showing
2 changed files
with
32 additions
and
20 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
platform/wab/src/wab/client/components/widgets/InfoTooltip.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { InlineIcon } from "@/wab/client/components/widgets"; | ||
import { Icon } from "@/wab/client/components/widgets/Icon"; | ||
import InfoIcon from "@/wab/client/plasmic/plasmic_kit/PlasmicIcon__Info"; | ||
import { Popover } from "antd"; | ||
import { isFunction } from "lodash"; | ||
import React, { ReactNode } from "react"; | ||
|
||
export type InfoTooltipProps = { | ||
tooltip: ReactNode | (() => React.ReactNode); | ||
}; | ||
|
||
export function InfoTooltip({ tooltip }: InfoTooltipProps) { | ||
return ( | ||
<InlineIcon> | ||
<Popover | ||
trigger={["hover", "click"]} | ||
mouseEnterDelay={0.5} | ||
// Place it over dropdown menus (1050), since it can be inside dropdown menus (default is 1030) | ||
overlayStyle={{ zIndex: 1080 }} | ||
content={() => ( | ||
<div style={{ maxWidth: 300 }}> | ||
{isFunction(tooltip) ? tooltip() : tooltip} | ||
</div> | ||
)} | ||
> | ||
<Icon icon={InfoIcon} className="dimfg pointer" /> | ||
</Popover> | ||
</InlineIcon> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters