feat(react): add tooltip component (#736)

This commit is contained in:
rahim
2026-03-04 23:20:16 -08:00
committed by GitHub
parent e9fbaece87
commit ae754eec8f
10 changed files with 406 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
'use client';
import type { StateAttrMap, TooltipCore } from '@videojs/core';
import type { TooltipApi } from '@videojs/core/dom';
import { createContext, useContext } from 'react';
export interface TooltipContextValue {
core: TooltipCore;
tooltip: TooltipApi;
state: TooltipCore.State;
stateAttrMap: StateAttrMap<TooltipCore.State>;
anchorName: string;
popupId: string;
}
const TooltipContext = createContext<TooltipContextValue | null>(null);
export const TooltipContextProvider = TooltipContext.Provider;
export function useTooltipContext(): TooltipContextValue {
const ctx = useContext(TooltipContext);
if (!ctx) throw new Error('Tooltip compound components must be used within a Tooltip.Root');
return ctx;
}