()
| 5 | import { getImageOriginRect } from '../components/modals/ImageModal'; |
| 6 | |
| 7 | export const useImageViewer = () => { |
| 8 | const { openModal } = useLazyModal(); |
| 9 | const { isCompanion } = useRequestProtocol(); |
| 10 | |
| 11 | return useCallback( |
| 12 | (src: string, alt: string | undefined, originElement: Element) => { |
| 13 | if (isCompanion) { |
| 14 | window.open(src, '_blank', 'noopener,noreferrer'); |
| 15 | return; |
| 16 | } |
| 17 | |
| 18 | openModal({ |
| 19 | type: LazyModal.ImageView, |
| 20 | props: { |
| 21 | src, |
| 22 | alt, |
| 23 | originRect: getImageOriginRect(originElement), |
| 24 | }, |
| 25 | }); |
| 26 | }, |
| 27 | [isCompanion, openModal], |
| 28 | ); |
| 29 | }; |
no test coverage detected