react-blurish-image
Version:
A lightweight, optimized React image component with blur placeholders and lazy loading
26 lines • 1.34 kB
TypeScript
import type { ImageLoader } from './types';
export declare const defaultLoader: ImageLoader;
/**
* Generates a base64-encoded data URL containing a blurred gradient background image.
* This function creates a small canvas element with a gradient and converts it to a low-quality JPEG data URL.
* It's commonly used for generating placeholder images or blur-up effects.
*
* @param {number} [width=8] - The width of the generated blur image in pixels
* @param {number} [height=8] - The height of the generated blur image in pixels
* @returns {string} A base64-encoded data URL of the generated blur image, or an empty string if generation fails
*
* @example
* ```typescript
* const blurDataURL = generateBlurDataURL(10, 10);
* // Returns: "data:image/jpeg;base64,..."
* ```
*
* @throws {Error} Will not throw directly but logs a warning if canvas operations fail
* @remarks
* - Only works in browser environments where `window` and `document` are available
* - Returns empty string in non-browser environments or if canvas operations fail
* - Uses a gray gradient pattern (f0f0f0 to d0d0d0)
*/
export declare const generateBlurDataURL: (width?: number, height?: number) => string;
export declare function useMergedRef<T>(...refs: Array<React.Ref<T> | undefined>): (value: T) => void;
//# sourceMappingURL=utils.d.ts.map