signal-desktop/ts/components/conversation/media-gallery/ImageThumbnail.tsx

55 lines
964 B
TypeScript
Raw Normal View History

2018-04-12 16:23:26 -04:00
import React from 'react';
import { LoadingIndicator } from './LoadingIndicator';
import { Message } from './propTypes/Message';
interface Props {
message: Message;
i18n: (value: string) => string;
}
2018-04-12 20:56:05 -04:00
const size = {
width: 94,
height: 94,
};
2018-04-12 16:23:26 -04:00
const styles = {
container: {
2018-04-12 20:56:05 -04:00
...size,
2018-04-12 16:23:26 -04:00
backgroundColor: '#f3f3f3',
marginRight: 4,
marginBottom: 4,
2018-04-12 20:56:05 -04:00
},
image: {
...size,
backgroundSize: 'cover',
2018-04-12 16:23:26 -04:00
},
};
export class ImageThumbnail extends React.Component<Props, {}> {
public renderContent() {
2018-04-12 20:56:05 -04:00
const {/* i18n, */message } = this.props;
2018-04-12 16:23:26 -04:00
2018-04-12 20:56:05 -04:00
if (!message.objectURL) {
2018-04-12 16:23:26 -04:00
return <LoadingIndicator />;
}
return (
2018-04-12 20:56:05 -04:00
<div
style={{
...styles.container,
...styles.image,
backgroundImage: `url("${message.objectURL}")`,
}}
2018-04-12 16:23:26 -04:00
/>
);
}
public render() {
return (
<div style={styles.container}>
{this.renderContent()}
</div>
);
}
}