imageViewer.tsx 837 B

12345678910111213141516171819202122232425262728293031323334
  1. import styled from '@emotion/styled';
  2. import {
  3. getAttachmentUrl,
  4. ViewerProps,
  5. } from 'sentry/components/events/attachmentViewers/utils';
  6. import {PanelItem} from 'sentry/components/panels';
  7. type Props = Omit<ViewerProps, 'attachment'> & {
  8. attachment: Omit<ViewerProps['attachment'], 'event_id'> & {
  9. event_id?: string;
  10. };
  11. onError?: React.ReactEventHandler<HTMLImageElement>;
  12. onLoad?: React.ReactEventHandler<HTMLImageElement>;
  13. };
  14. function ImageViewer({className, onLoad, onError, ...props}: Props) {
  15. return (
  16. <Container className={className}>
  17. <img
  18. data-test-id="image-viewer"
  19. src={getAttachmentUrl(props, true)}
  20. onLoad={onLoad}
  21. onError={onError}
  22. />
  23. </Container>
  24. );
  25. }
  26. export default ImageViewer;
  27. const Container = styled(PanelItem)`
  28. justify-content: center;
  29. `;