Skip to content

Commit

Permalink
feat: add svg image class to attachment
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinCupela committed Aug 22, 2022
1 parent f5a8816 commit 3d0237d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/Attachment/AttachmentContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { FileAttachment as DefaultFile } from './FileAttachment';
import {
AttachmentContainerProps,
isGalleryAttachmentType,
isSvgAttachment,
RenderAttachmentProps,
RenderGalleryProps,
} from './utils';
Expand Down Expand Up @@ -39,6 +40,7 @@ export const AttachmentWithinContainer = <
[`str-chat__message-attachment--${componentType}`]: componentType,
[`str-chat__message-attachment--${attachment?.type}`]: attachment?.type,
[`str-chat__message-attachment--${componentType}--${extra}`]: componentType && extra,
'str-chat__message-attachment--svg-image': isSvgAttachment(attachment),
'str-chat__message-attachment-with-actions': extra === 'actions', // added for theme V2 (better readability)
});

Expand Down
6 changes: 6 additions & 0 deletions src/components/Attachment/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ export const isMediaAttachment = <
(attachment.mime_type && SUPPORTED_VIDEO_FORMATS.indexOf(attachment.mime_type) !== -1) ||
attachment.type === 'video';

export const isSvgAttachment = (attachment: Attachment) => {
const filename = attachment.fallback || '';
return filename.toLowerCase().endsWith('.svg');
};

/**
* @deprecated will be removed in the next major release,
* replaced with the proper component equivalent `AttachmentContainer/AttachmentWithinContainer`
Expand All @@ -113,6 +118,7 @@ export const renderAttachmentWithinContainer = <
[`str-chat__message-attachment--${componentType}`]: componentType,
[`str-chat__message-attachment--${attachment?.type}`]: attachment?.type,
[`str-chat__message-attachment--${componentType}--${extra}`]: componentType && extra,
'str-chat__message-attachment--svg-image': isSvgAttachment(attachment),
'str-chat__message-attachment-with-actions': extra === 'actions', // added for theme V2 (better readability)
});

Expand Down

0 comments on commit 3d0237d

Please sign in to comment.