import { CSSProperties } from 'react';
import { PopoverProps } from 'antd';
import { CarouselProps } from 'antd/lib/carousel';
type Position = 'topleft' | 'top' | 'topright' | 'right' | 'bottomright' | 'bottom' | 'bottomleft' | 'left';
export type ImageDetail = {
url: string;
alt?: string;
caption?: string;
};
export type CaptionConfiguration = {
/**
* The position of the caption overlay
*/
position?: Position;
/**
* Any CSS style for the caption
*/
style?: CSSProperties;
};
export type MagnifierConfiguration = {
/**
* Must include px or % or be a number
* @default '25%'
*/
size?: string | number;
/**
* Allows the magnifying glass to spill out over the edges of the component
* @default true
*/
allowOverflow?: boolean;
/**
* Border color for the magnifying glass
* @default 'rgba(225, 225, 225, 0.5)'
*/
borderColor?: string;
/**
* Border size for the magnifying glass
* @default 3
*/
borderSize?: number;
/**
* Horizontal offset of the magnifying glass from the mouse position
* @default 0
*/
offsetX?: number;
/**
* Vertical offset of the magnifying glass from the mouse position
* @default 0
*/
offsetY?: number;
/**
* The shape of the magnifying glass
* @default 'circle'
*/
shape?: 'square' | 'circle';
/**
* Background color fo the magnifying glass which is only visible when allowOverflow=true and magnifying glass is at edge of screen
* @default 'rgba(225, 225, 225, 0.5)'
*/
backgroundColor?: string;
};
export type ToolbarConfiguration = {
/**
* Function to return the content of the toolbar
*/
getToolbarContent(imageIndex: number): JSX.Element | string;
/**
* The position of the toolbar which will overlay above the image on expand
* @default topright
*/
position?: Position;
/**
* Any props to provide to AntD's popover
* @default {}
*/
popoverProps?: PopoverProps;
/**
* The content to trigger the menu
* @default {}
*/
triggerContent?: JSX.Element | string;
};
export interface ImageViewerProps extends CarouselProps {
/**
* The list of images to show, described by an ImageDetail comprising of:
* - url `string` The URL of the image to display
* - alt? `string` The text alternative to describe the image
* - caption? `string` The image caption to diplay
*/
images: ImageDetail[];
/**
* Whether or not to enable a magnifying glass effect on the image. See `magnifierConfiguration` for more options.
*/
magnifierEnabled?: boolean;
/**
* Whether or not to enable a toolbar which comprises of additional actions. See `toolbarConfiguration` for more options.
* @default false
*/
toolbarEnabled?: boolean;
/**
* Define the width for the image viewer
*/
width?: number | string;
/**
* Define the height for this image viewer
*/
height?: number | string;
/**
* If the magnifier is enabled, then its configuration can be overriden with the following props:
* - size? `string | number` The size of the magnifier. @default `25%`
* - allowOverflow? `boolean` Whether or not to allow the magnifying glass to spill out over the edges of the component. @default `true`
* - borderColor? `string` The border color for the magnifying glass. @default `rgba(225, 225, 225, 0.5)`
* - borderSize? `number` The b size for the magnifying glass. @default `3`
* - offsetX? `number` The horizontal offset of the magnifying glass from the mouse position. @default `0`
* - offsetY? `number` The vertical offset of the magnifying glass from the mouse position. @default `0`
* - shape? `'square' | 'circle'` The shape of the magnifying glass. @default `circle`
* - backgroundColor? `string` The background color fo the magnifying glass which is only visible when allowOverflow=true and magnifying glass is at edge of screen. @default `rgba(225, 225, 225, 0.5)`
*/
magnifierConfiguration?: MagnifierConfiguration;
/**
* If the toolbar is enabled, then its configuration can be overriden with the following props:
* - getToolbarContent `(imageIndex: number): JSX.Element | string` Function that returns the content of the toolbar
* - position? `'topleft' | 'top' | 'topright' | 'right' | 'bottomright' | 'bottom' | 'bottomleft' | 'left'` The position of the toolbar which will overlay above the image. @default `topright`
* - popoverProps? `PopoverProps` Any props that overrides AntDesign's Popover. @default `{}`
* - triggerContent? `JSX.Element | string` The content to trigger the menu dropdown. @default ``
*/
toolbarConfiguration?: ToolbarConfiguration;
/**
* If captions are provided in an ImageDetail, then its configuration can be overriden with the following props:
* - position? `'topleft' | 'top' | 'topright' | 'right' | 'bottomright' | 'bottom' | 'bottomleft' | 'left'` The position of the caption which will overlay above the image. @default `topright`
* - style? `CSSProperties` Any CSS styling for the caption. @default `{ width: '100%', color: 'white', padding: 10, }`
*/
captionConfiguration?: CaptionConfiguration;
}