aboutsummaryrefslogtreecommitdiffstats
path: root/client/src/ui/Attachment.js
blob: 3c07ee54f07dcc44869f5c12bf8ecd0c75a31a64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { h } from 'preact';
import css from './css';

css`
.attachment {
	margin: 1rem;

	height: 7rem;
	object-fit: contain;
}

.attachment + .attachment {
	margin-top: 0;
}
`;

export const Attachment = ({ type, mediaType, url, style }) => {
	let content;
	if (mediaType.startsWith('video/')) {
		content = <video class="attachment" src={url} controls />;
	} else if (mediaType.startsWith('image/')) {
		content = <img class="attachment" src={url} />;
	}

	return content;
}