@patreon/studio
Version:
Patreon Studio Design System
26 lines (25 loc) • 1.16 kB
TypeScript
import type { Breakpoint } from '../../utilities/opaque-responsive';
/** the pending result is what we return on before the breakpoint can be determined from the window */
interface PendingBreakpointResult {
state: 'pending';
}
/** the available result is what we return once the breakpoint can be determined from the window */
interface AvailableBreakpointResult {
state: 'available';
value: Breakpoint;
}
/** the result is either the initial result or the defined result */
declare type CurrentBreakpointResult = PendingBreakpointResult | AvailableBreakpointResult;
/**
* This helper returns true if the current breakpoint result is yet available
*/
export declare function isBreakpointAvailable(result: CurrentBreakpointResult): result is AvailableBreakpointResult;
/**
* This hook returns the current breakpoint when it is available.
* It will return a tagged object with a state of "inital" until the
* breakpoint is hydrated on the client. Once the breakpoint is
* hydrated, the hook will return a breakpoint object with a state
* of "defined".
*/
export declare function useCurrentBreakpoint(): CurrentBreakpointResult;
export {};