gif-picker-react
Version:
Multi-provider GIF Picker for React with pluggable provider support
75 lines • 2.03 kB
text/typescript
//#region src/types/types.d.ts
type Awaitable<T> = T | PromiseLike<T>;
type GifCategory = {
imageUrl: string;
name: string; /** Term searched when the category is clicked. Falls back to `name`. */
searchTerm?: string;
};
type GifPreview = {
imageUrl: string;
height: number;
width: number;
};
type Gif<T = unknown> = {
id: string;
imageUrl: string;
height: number;
width: number;
description?: string;
preview?: GifPreview;
provider: string;
raw: T;
};
//#endregion
//#region src/types/GifProvider.d.ts
interface GifProvider {
/**
* Fetches list of currently featured, trending or home page GIFs
*/
getTrending(): Awaitable<Gif[]>;
/**
* Fetches most popular GIFs categories with their cover images
*/
getCategories(): Awaitable<GifCategory[]>;
/**
* Searches GIFs by user-provided search term
*/
search(term: string): Awaitable<Gif[]>;
/**
* If provider supports it, invoked after gif is clicked. This may
* be required by provider for analytics.
*/
onClick?(gif: Gif, context: GifEventContext): Awaitable<void>;
/**
* If provider supports it, invoked after gif image loads. This may
* be required by provider for analytics.
*/
onLoad?(gif: Gif, context: GifEventContext): Awaitable<void>;
/**
* Provides configuration of required attribution rules for
* specific provider.
*/
getAttribution?(): Partial<GifProviderAttribution>;
}
type GifEventContext = {
searchTerm?: string;
};
type GifProviderAttribution = {
/**
* Placeholder shown in the search input, used instead of the default
* "Search GIFs".
*/
searchPlaceholder: string;
/**
* Optional provider logo shown in the picker footer (e.g. a "Powered by ..." mark).
*/
branding?: {
logo: string;
href: string;
logoDark?: string;
alt?: string;
};
};
//#endregion
export { GifCategory as a, Gif as i, GifProvider as n, GifPreview as o, GifProviderAttribution as r, GifEventContext as t };
//# sourceMappingURL=GifProvider-CmpIJXla.d.cts.map