|
| 1 | + import React from 'react' |
| 2 | + |
| 3 | + type ClassName = string | Record<string, unknown> |
| 4 | + |
| 5 | + export interface GraphImageProp { |
| 6 | + handle: string |
| 7 | + height: number |
| 8 | + width: number |
| 9 | + } |
| 10 | + |
| 11 | + export interface GraphImageProps { |
| 12 | + /** |
| 13 | + * Passed to the img element |
| 14 | + */ |
| 15 | + title?: string |
| 16 | + /** |
| 17 | + * Passed to the img element |
| 18 | + */ |
| 19 | + alt?: string |
| 20 | + /** |
| 21 | + * Passed to the wrapper `div`. Object is needed to support Glamor's css prop |
| 22 | + */ |
| 23 | + className?: ClassName |
| 24 | + /** |
| 25 | + * Passed to the outer wrapper `div`. Object is needed to support Glamor's css prop |
| 26 | + */ |
| 27 | + outerWrapperClassName?: ClassName |
| 28 | + /** |
| 29 | + * Spread into the default styles in the wrapper `div` |
| 30 | + */ |
| 31 | + style?: React.CSSProperties |
| 32 | + /** |
| 33 | + * An object of shape `{ handle, width, height }`. Handle is an identifier required to display the image |
| 34 | + * and both `width` and `height` are required to display a correct placeholder and aspect ratio for the image. |
| 35 | + * You can get all 3 by just putting all 3 in your image-getting query. |
| 36 | + */ |
| 37 | + image: GraphImageProp |
| 38 | + /** |
| 39 | + * When resizing the image, how would you like it to fit the new dimensions? |
| 40 | + * Defaults to crop. You can read more about resizing [here](https://www.filestack.com/docs/image-transformations/resize) |
| 41 | + */ |
| 42 | + fit?: 'clip' | 'crop' | 'scale' | 'max' |
| 43 | + /** |
| 44 | + * Maximum width you'd like your image to take up. |
| 45 | + * (ex. If your image container is resizing dynamically up to a width of 1200, put it as a `maxWidth`) |
| 46 | + */ |
| 47 | + maxWidth?: number |
| 48 | + /** |
| 49 | + * If webp is supported by the browser, the images will be served with `.webp` extension. (Recommended) |
| 50 | + */ |
| 51 | + withWebp?: boolean |
| 52 | + /** |
| 53 | + * Array of `string`s, each representing a separate Filestack transform, |
| 54 | + * eg. `['sharpen=amount:5', 'quality=value:75']` |
| 55 | + */ |
| 56 | + transforms?: string[] |
| 57 | + /** |
| 58 | + * A callback that is called when the full-size image has loaded. |
| 59 | + */ |
| 60 | + onLoad?: () => void |
| 61 | + /** |
| 62 | + * Would you like to display a blurry placeholder for your loading image? Defaults to `true`. |
| 63 | + */ |
| 64 | + blurryPlaceholder?: boolean |
| 65 | + /** |
| 66 | + * Set a colored background placeholder. If true, uses "lightgray" for the color. |
| 67 | + * You can also pass in any valid color string. |
| 68 | + */ |
| 69 | + backgroundColor?: string | boolean |
| 70 | + /** |
| 71 | + * Do you want your image to fade in on load? Defaults to `true` |
| 72 | + */ |
| 73 | + fadeIn?: boolean |
| 74 | + /** |
| 75 | + * Set the base src from where the images are requested. |
| 76 | + * Base URI Defaults to `https://media.graphcms.com` |
| 77 | + */ |
| 78 | + baseURI?: string |
| 79 | + } |
| 80 | + |
| 81 | + export default class GraphImage extends React.Component<GraphImageProps> {} |
0 commit comments