mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
dae1bce48c
* Convert Tooltip component from Tippy.js to Radix UI - Replace @tippyjs/react with @radix-ui/react-tooltip - Maintain backward compatibility with existing props (placement, delay, offset) - Convert TooltipContext from singleton pattern to provider pattern - Update editor Tooltip wrapper to use new props - Remove TippyProps references from ToolbarMenu - Preserve styling with styled-components and animations - Remove @tippyjs/react dependency from package.json * Fix linting issues in Tooltip components - Move keyframes definitions before usage in Tooltip.tsx - Replace 'any' type with specific type in TooltipContext.tsx - Add ESLint disable comments for keyframes used in styled-components * Fix ESLint issues in Tooltip components - Move keyframes definitions before styled components that use them - Fix TypeScript any type in TooltipContext - Add ESLint disable comments for keyframes variables that are used in template literals * Fix TypeScript and ESLint errors - Add proper return type annotation to Tooltip component - Remove duplicate keyframes definitions - Fix children return type casting - Remove deprecated hideOnClick prop from components - All TypeScript and ESLint checks now pass * fix * tidy animation --------- Co-authored-by: codegen-sh[bot] <131295404+codegen-sh[bot]@users.noreply.github.com> Co-authored-by: Tom Moor <tom@getoutline.com>
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
import * as React from "react";
|
|
|
|
export const TooltipContext = React.createContext<boolean>(false);
|
|
|
|
export function useTooltipContext() {
|
|
return React.useContext(TooltipContext);
|
|
}
|
|
|
|
type Props = {
|
|
children: React.ReactNode;
|
|
/** The duration from when the mouse enters the trigger until the tooltip gets opened */
|
|
delayDuration?: number;
|
|
/** How much time a user has to enter another trigger without incurring a delay again */
|
|
skipDelayDuration?: number;
|
|
/** Prevents the tooltip from opening */
|
|
disableHoverableContent?: boolean;
|
|
/** Props to pass to the Tippy component - kept for backward compatibility */
|
|
tippyProps?: {
|
|
delay?: number;
|
|
[key: string]: unknown;
|
|
};
|
|
};
|
|
|
|
/**
|
|
* Wrap a collection of tooltips in a provider to allow them to share the same provider instance.
|
|
*/
|
|
export function TooltipProvider({
|
|
children,
|
|
delayDuration = 500,
|
|
skipDelayDuration = 300,
|
|
disableHoverableContent = false,
|
|
tippyProps,
|
|
}: Props) {
|
|
// Handle backward compatibility with tippyProps
|
|
const finalDelayDuration = tippyProps?.delay ?? delayDuration;
|
|
|
|
return (
|
|
<TooltipPrimitive.Provider
|
|
delayDuration={finalDelayDuration}
|
|
skipDelayDuration={skipDelayDuration}
|
|
disableHoverableContent={disableHoverableContent}
|
|
>
|
|
<TooltipContext.Provider value={true}>{children}</TooltipContext.Provider>
|
|
</TooltipPrimitive.Provider>
|
|
);
|
|
}
|