@primer/react-brand
Version:
Primer Brand is a GitHub's design system for creating React-based marketing websites and digital experiences.
21 lines (20 loc) • 1.05 kB
TypeScript
import React, { RefObject } from 'react';
import type { AnchorPosition, PositionSettings } from '@primer/behaviors';
export type AnchoredPositionHookSettings = Partial<PositionSettings> & {
floatingElementRef?: React.RefObject<Element>;
anchorElementRef?: React.RefObject<Element>;
};
/**
* Calculates the top and left values for an absolutely-positioned floating element
* to be anchored to some anchor element. Returns refs for the floating element
* and the anchor element, along with the position.
* @param settings Settings for calculating the anchored position.
* @param dependencies Dependencies to determine when to re-calculate the position.
* @returns An object of {top: number, left: number} to absolutely-position the
* floating element.
*/
export declare function useAnchoredPosition(settings?: AnchoredPositionHookSettings, dependencies?: React.DependencyList): {
floatingElementRef: RefObject<Element> | undefined;
anchorElementRef: RefObject<Element> | undefined;
position: AnchorPosition | undefined;
};