Skip to content

Commit

Permalink
[@mantine/core] Tooltip: Add nested tooltips support (#2768)
Browse files Browse the repository at this point in the history
  • Loading branch information
nfbuckley committed Oct 22, 2022
1 parent a1f5fbf commit 158bf10
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/mantine-core/src/Tooltip/Tooltip.tsx
Expand Up @@ -179,6 +179,9 @@ const _Tooltip = forwardRef<HTMLElement, TooltipProps>((props, ref) => {
onClick,
onMouseEnter,
onMouseLeave,
onMouseMove: props.onMouseMove,
onPointerDown: props.onPointerDown,
onPointerEnter: props.onPointerEnter,
[refProp]: targetRef,
className: cx(className, children.props.className),
...children.props,
Expand Down
61 changes: 61 additions & 0 deletions src/mantine-demos/src/demos/core/Tooltip/Tooltip.demo.nested.tsx
@@ -0,0 +1,61 @@
import React from 'react';
import { MantineDemo } from '@mantine/ds';
import { Tooltip, Button, Group } from '@mantine/core';

const code = `
import { Tooltip, Button } from '@mantine/core';
function Demo() {
return (
<Tooltip
label="top"
position="top"
closeDelay={1500}
>
<Tooltip
label="bottom"
position="bottom"
openDelay={500}
closeDelay={1000}
>
<Tooltip
label="left"
position="left"
openDelay={1000}
closeDelay={500}
>
<Tooltip
label="right"
position="right"
openDelay={1500}
>
<Button variant="outline">Nested Tooltips</Button>
</Tooltip>
</Tooltip>
</Tooltip>
</Tooltip>
);
}
`;

function Demo() {
return (
<Group position="center">
<Tooltip label="top" position="top" closeDelay={1500}>
<Tooltip label="bottom" position="bottom" openDelay={500} closeDelay={1000}>
<Tooltip label="left" position="left" openDelay={1000} closeDelay={500}>
<Tooltip label="right" position="right" openDelay={1500}>
<Button variant="outline">Nested Tooltips</Button>
</Tooltip>
</Tooltip>
</Tooltip>
</Tooltip>
</Group>
);
}

export const nested: MantineDemo = {
type: 'demo',
component: Demo,
code,
};
1 change: 1 addition & 0 deletions src/mantine-demos/src/demos/core/Tooltip/index.ts
Expand Up @@ -9,3 +9,4 @@ export { usage } from './Tooltip.demo.usage';
export { group } from './Tooltip.demo.group';
export { offset } from './Tooltip.demo.offset';
export { inline } from './Tooltip.demo.inline';
export { nested } from './Tooltip.demo.nested';

0 comments on commit 158bf10

Please sign in to comment.