diff --git a/packages/react/src/components/Attachments/AttachmentMetadata.js b/packages/react/src/components/Attachments/AttachmentMetadata.js new file mode 100644 index 000000000..3e8aee462 --- /dev/null +++ b/packages/react/src/components/Attachments/AttachmentMetadata.js @@ -0,0 +1,39 @@ +import React from 'react'; +import { ActionButton } from '../ActionButton'; +import { Box } from '../Box'; + +const AttachmentMetadata = ({ attachment, url }) => { + const handleDownload = () => { + const anchor = document.createElement('a'); + anchor.href = url; + anchor.download = attachment.title; + + document.body.appendChild(anchor); + anchor.click(); + document.body.removeChild(anchor); + }; + + return ( + <> +

{attachment.description}

+ +

{attachment.title}

+ +
+ + ); +}; + +export default AttachmentMetadata; diff --git a/packages/react/src/components/Attachments/AudioAttachment.js b/packages/react/src/components/Attachments/AudioAttachment.js index f2349ce39..fe1da9406 100644 --- a/packages/react/src/components/Attachments/AudioAttachment.js +++ b/packages/react/src/components/Attachments/AudioAttachment.js @@ -1,10 +1,14 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Box } from '../Box'; +import AttachmentMetadata from './AttachmentMetadata'; const AudioAttachment = ({ attachment, host }) => ( -

{attachment?.description}

+
); diff --git a/packages/react/src/components/Attachments/ImageAttachment.js b/packages/react/src/components/Attachments/ImageAttachment.js index e3a650be8..7d356ba92 100644 --- a/packages/react/src/components/Attachments/ImageAttachment.js +++ b/packages/react/src/components/Attachments/ImageAttachment.js @@ -1,10 +1,14 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Box } from '../Box'; +import AttachmentMetadata from './AttachmentMetadata'; const ImageAttachment = ({ attachment, host }) => ( -

{attachment?.description}

+ ( -

{attachment?.description}

+ diff --git a/packages/react/src/components/Icon/icons/Download.js b/packages/react/src/components/Icon/icons/Download.js new file mode 100644 index 000000000..7127ed3e3 --- /dev/null +++ b/packages/react/src/components/Icon/icons/Download.js @@ -0,0 +1,14 @@ +import React from 'react'; + +const Download = (props) => ( + + + +); + +export default Download; diff --git a/packages/react/src/components/Icon/icons/index.js b/packages/react/src/components/Icon/icons/index.js index b66ac20cc..13cf98f97 100644 --- a/packages/react/src/components/Icon/icons/index.js +++ b/packages/react/src/components/Icon/icons/index.js @@ -39,6 +39,7 @@ import PinFilled from './PinFilled'; import VideoRecorder from './VideoRecoder'; import DisabledRecorder from './DisableRecorder'; import Clipboard from './Clipboard'; +import Download from './Download'; import At from './At'; const icons = { @@ -83,6 +84,7 @@ const icons = { 'arrow-down': ArrowDown, 'pin-filled': PinFilled, clipboard: Clipboard, + download: Download, at: At, };