dap-design-system
Version:
Official design system for the DÁP (dap.gov.hu)
29 lines (28 loc) • 1.65 kB
TypeScript
import { Size } from './types';
export type BreakpointName = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
/**
* Map from breakpoint to component size. A key applies at that breakpoint and all narrower ones (e.g. md:lg → xs, sm, md use lg).
*/
export type BreakpointToSizeMap = Partial<Record<BreakpointName, Size>>;
/**
* Parses a string like "sm:lg,md:md" into a BreakpointToSizeMap.
* Key = breakpoint (xs, sm, md, lg, xl, 2xl). Value = component size (xxs, xs, sm, md, lg).
* Invalid pairs are skipped. Returns undefined for empty/null/whitespace.
*/
export declare function parseResponsiveSizeMap(value: string | null | undefined): BreakpointToSizeMap | undefined;
/**
* Returns the effective component size from the breakpoint→size map.
* A map entry like "md:lg" applies at that breakpoint and all narrower breakpoints (xs, sm, md).
* With multiple entries we use the narrowest matching key (most specific). E.g. "sm:lg,md:md" → xs/sm use lg, md uses md.
*/
export declare function getResponsiveSize(requestedSize: Size, breakpointToSizeMap: BreakpointToSizeMap | null | undefined): Size;
/**
* Subscribes to viewport changes at the given breakpoint. The callback is invoked
* when the viewport crosses the breakpoint. Returns an unsubscribe function.
*/
export declare function subscribeToBreakpoint(breakpoint: BreakpointName, callback: () => void): () => void;
/**
* Subscribes to multiple breakpoints; callback runs when any of them is crossed.
* Returns a single unsubscribe that removes all listeners.
*/
export declare function subscribeToBreakpoints(breakpoints: BreakpointName[], callback: () => void): () => void;