@patreon/studio
Version:
Patreon Studio Design System
42 lines (41 loc) • 1.86 kB
TypeScript
import type { IncrementLoggerFn } from '~/components/IncrementLogger';
import type { Breakpoint, OpaqueResponsive } from '~/utilities/opaque-responsive';
type LookupFunction<T extends string> = (responsiveValue: T, breakpoint: Breakpoint) => string;
/**
* Helper function to generate a responsive class name lookup function
* that takes a responsive value and returns a class name for the
* responsive value.
*
* @warning This should be used outside of the React render function
* to validate failures before they occur in the render lifecycle.
*/
export declare function createResponsiveClassNameLookup<T extends string>(
/** CSS modules styles object */
styles: Record<string, string>,
/** Object describing the class names for each option value */
options: Record<T, string>): LookupFunction<T>;
/**
* Generates a CSS class name for a responsive value using a lookup function
* that takes a responsive value and breakpoint then returns a class name
* for the responsive value.
*/
export declare function classNameForResponsiveValue<T extends string>(
/** responsive value to generate the class name */
responsiveValue: OpaqueResponsive<T>,
/** lookup function to use to generate the class name per breakpoint */
lookupFunction: LookupFunction<T>): string;
/**
* Wraps a classNameForResponsiveValue function in a try/catch block that
* catches errors and logs them to the incrementLogger. If an error is caught,
* it returns an empty string.
*
* @warning this is not general purpose and should only be used to track down
* deprecated properties that are no longer supported.
*/
export declare function safeResponsiveClassNameFor<T>({ classNameFn, props, incrementLogger, incrementName, }: {
classNameFn: (config: T) => string;
props: T;
incrementLogger: IncrementLoggerFn;
incrementName: string;
}): string;
export {};