mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-08-22 12:19:24 +00:00
fix flashing tooltip issue
This commit is contained in:
parent
710c5e7a5e
commit
c4e81979ce
@ -29,7 +29,8 @@ const AllToolsNavButton: React.FC<AllToolsNavButtonProps> = ({ activeButton, set
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip content={'All tools'} sidebarTooltip>
|
|
||||||
|
<Tooltip content={'All tools'} position="right" arrow containerStyle={{ marginTop: "-1rem" }} maxWidth={200}>
|
||||||
<div className="flex flex-col items-center gap-1 mt-4 mb-2">
|
<div className="flex flex-col items-center gap-1 mt-4 mb-2">
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
size={'lg'}
|
size={'lg'}
|
||||||
|
@ -178,7 +178,7 @@ const QuickAccessBar = forwardRef<HTMLDivElement>(({
|
|||||||
<Stack gap="lg" align="center">
|
<Stack gap="lg" align="center">
|
||||||
{buttonConfigs.slice(0, -1).map((config, index) => (
|
{buttonConfigs.slice(0, -1).map((config, index) => (
|
||||||
<React.Fragment key={config.id}>
|
<React.Fragment key={config.id}>
|
||||||
<Tooltip content={config.tooltip} sidebarTooltip>
|
<Tooltip content={config.tooltip} position="right" arrow containerStyle={{ marginTop: "-1rem" }} maxWidth={200}>
|
||||||
<div className="flex flex-col items-center gap-1" style={{ marginTop: index === 0 ? '0.5rem' : "0rem" }}>
|
<div className="flex flex-col items-center gap-1" style={{ marginTop: index === 0 ? '0.5rem' : "0rem" }}>
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
size={isButtonActive(config) ? (config.size || 'xl') : 'lg'}
|
size={isButtonActive(config) ? (config.size || 'xl') : 'lg'}
|
||||||
|
@ -14,6 +14,7 @@ export interface TooltipProps {
|
|||||||
children: React.ReactElement;
|
children: React.ReactElement;
|
||||||
offset?: number;
|
offset?: number;
|
||||||
maxWidth?: number | string;
|
maxWidth?: number | string;
|
||||||
|
minWidth?: number | string;
|
||||||
open?: boolean;
|
open?: boolean;
|
||||||
onOpenChange?: (open: boolean) => void;
|
onOpenChange?: (open: boolean) => void;
|
||||||
arrow?: boolean;
|
arrow?: boolean;
|
||||||
@ -23,6 +24,7 @@ export interface TooltipProps {
|
|||||||
logo?: React.ReactNode;
|
logo?: React.ReactNode;
|
||||||
};
|
};
|
||||||
delay?: number;
|
delay?: number;
|
||||||
|
containerStyle?: React.CSSProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Tooltip: React.FC<TooltipProps> = ({
|
export const Tooltip: React.FC<TooltipProps> = ({
|
||||||
@ -32,13 +34,15 @@ export const Tooltip: React.FC<TooltipProps> = ({
|
|||||||
tips,
|
tips,
|
||||||
children,
|
children,
|
||||||
offset: gap = 8,
|
offset: gap = 8,
|
||||||
maxWidth = 280,
|
maxWidth,
|
||||||
|
minWidth,
|
||||||
open: controlledOpen,
|
open: controlledOpen,
|
||||||
onOpenChange,
|
onOpenChange,
|
||||||
arrow = false,
|
arrow = false,
|
||||||
portalTarget,
|
portalTarget,
|
||||||
header,
|
header,
|
||||||
delay = 0,
|
delay = 0,
|
||||||
|
containerStyle={},
|
||||||
}) => {
|
}) => {
|
||||||
const [internalOpen, setInternalOpen] = useState(false);
|
const [internalOpen, setInternalOpen] = useState(false);
|
||||||
const [isPinned, setIsPinned] = useState(false);
|
const [isPinned, setIsPinned] = useState(false);
|
||||||
@ -135,8 +139,8 @@ export const Tooltip: React.FC<TooltipProps> = ({
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
// Only show tooltip when position is ready and correct
|
// Always mount when open so we can measure; hide until positioned to avoid flash
|
||||||
const shouldShowTooltip = open && (sidebarTooltip ? positionReady : true);
|
const shouldShowTooltip = open;
|
||||||
|
|
||||||
const tooltipElement = shouldShowTooltip ? (
|
const tooltipElement = shouldShowTooltip ? (
|
||||||
<div
|
<div
|
||||||
@ -145,11 +149,13 @@ export const Tooltip: React.FC<TooltipProps> = ({
|
|||||||
position: 'fixed',
|
position: 'fixed',
|
||||||
top: coords.top,
|
top: coords.top,
|
||||||
left: coords.left,
|
left: coords.left,
|
||||||
maxWidth,
|
width: (maxWidth !== undefined ? maxWidth : '25rem'),
|
||||||
|
minWidth: minWidth,
|
||||||
zIndex: 9999,
|
zIndex: 9999,
|
||||||
visibility: 'visible',
|
visibility: positionReady ? 'visible' : 'hidden',
|
||||||
opacity: 1,
|
opacity: positionReady ? 1 : 0,
|
||||||
color: 'var(--text-primary)',
|
color: 'var(--text-primary)',
|
||||||
|
...containerStyle,
|
||||||
}}
|
}}
|
||||||
className={`${styles['tooltip-container']} ${isPinned ? styles.pinned : ''}`}
|
className={`${styles['tooltip-container']} ${isPinned ? styles.pinned : ''}`}
|
||||||
onClick={handleTooltipClick}
|
onClick={handleTooltipClick}
|
||||||
|
@ -68,7 +68,7 @@ const TopToolIndicator: React.FC<TopToolIndicatorProps> = ({ activeButton, setAc
|
|||||||
{indicatorTool && (
|
{indicatorTool && (
|
||||||
<div className="current-tool-content">
|
<div className="current-tool-content">
|
||||||
<div className="flex flex-col items-center gap-1">
|
<div className="flex flex-col items-center gap-1">
|
||||||
<Tooltip content={isBackHover ? 'Back to all tools' : indicatorTool.name} sidebarTooltip>
|
<Tooltip content={isBackHover ? 'Back to all tools' : indicatorTool.name} position="right" arrow width={140}>
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
size={'xl'}
|
size={'xl'}
|
||||||
variant="subtle"
|
variant="subtle"
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
z-index: 9999;
|
z-index: 9999;
|
||||||
transition: opacity 100ms ease-out, transform 100ms ease-out;
|
transition: opacity 100ms ease-out, transform 100ms ease-out;
|
||||||
min-width: 25rem;
|
|
||||||
max-width: 50vh;
|
max-width: 50vh;
|
||||||
max-height: 80vh;
|
max-height: 80vh;
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
|
1
frontend/src/global.d.ts
vendored
1
frontend/src/global.d.ts
vendored
@ -5,3 +5,4 @@ declare module "../components/PageEditor";
|
|||||||
declare module "../components/Viewer";
|
declare module "../components/Viewer";
|
||||||
declare module "*.js";
|
declare module "*.js";
|
||||||
declare module '*.module.css';
|
declare module '*.module.css';
|
||||||
|
declare module 'pdfjs-dist';
|
Loading…
x
Reference in New Issue
Block a user