docs: fixed tooltip causing overflow in codeblocks (#2679)
This commit is contained in:
1 parent
6aee2e2265
commit
2db038cd82
3 files changed
+12
-10
No files matched your search
@@ -1,11 +1,12 @@
|
|||||||
import React, {isValidElement} from 'react';
|
import React, {isValidElement} from 'react';
|
||||||
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
||||||
import useBaseUrl from '@docusaurus/useBaseUrl';
|
import CopyButton from '../CopyButton';
|
||||||
import ElementContent from '@theme/CodeBlock/Content/Element';
|
import ElementContent from '@theme/CodeBlock/Content/Element';
|
||||||
import StringContent from '@theme/CodeBlock/Content/String';
|
import StringContent from '@theme/CodeBlock/Content/String';
|
||||||
import ThemedImage from '@theme/ThemedImage';
|
import ThemedImage from '@theme/ThemedImage';
|
||||||
import Tooltip from '../Tooltip';
|
import Tooltip from '../Tooltip';
|
||||||
import CopyButton from '../CopyButton';
|
import useBaseUrl from '@docusaurus/useBaseUrl';
|
||||||
|
import useIsBrowser from '@docusaurus/useIsBrowser';
|
||||||
import {useThemeConfig} from '@docusaurus/theme-common';
|
import {useThemeConfig} from '@docusaurus/theme-common';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import copy from 'copy-text-to-clipboard';
|
|
||||||
import Tooltip from '../Tooltip';
|
import Tooltip from '../Tooltip';
|
||||||
|
import copy from 'copy-text-to-clipboard';
|
||||||
|
|
||||||
export default function CopyButton ({ children, buttonClassName, text, tooltipClassName }) {
|
export default function CopyButton ({ children, buttonClassName, text, tooltipClassName }) {
|
||||||
const [isCopied, setIsCopied] = useState(false);
|
const [isCopied, setIsCopied] = useState(false);
|
||||||
|
|||||||
@@ -4,17 +4,17 @@ export default function Tooltip ({ children, text, tooltipClassName, ...rest })
|
|||||||
const [show, setShow] = React.useState(false);
|
const [show, setShow] = React.useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`tooltip-container ${tooltipClassName || ''}`}>
|
<span className={`tooltip-container ${tooltipClassName || ''}`}>
|
||||||
<div className={show ? 'tooltip-box visible' : 'tooltip-box'}>
|
<span className={show ? 'tooltip-box visible' : 'tooltip-box'}>
|
||||||
{text}
|
{text}
|
||||||
</div>
|
</span>
|
||||||
<div
|
<span
|
||||||
onMouseEnter={() => setShow(true)}
|
onMouseEnter={() => setShow(true)}
|
||||||
onMouseLeave={() => setShow(false)}
|
onMouseLeave={() => setShow(false)}
|
||||||
{...rest}
|
{...rest}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</span>
|
||||||
</div>
|
</span>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user