mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
feat(react): add tooltip component (#736)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user