-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathImage.jsx
More file actions
38 lines (31 loc) · 771 Bytes
/
Image.jsx
File metadata and controls
38 lines (31 loc) · 771 Bytes
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
27
28
29
30
31
32
33
34
35
36
37
38
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
const Figure = styled.figure`
width: 150% !important;
margin: 3em;
`;
const Figcaption = styled.figcaption`
font-size: 0.8em;
margin: 0 1em;
opacity: 0.8;
`;
const Image = props => {
const { src, alt, caption } = props;
const image = require(`../../src/images/img/articles/${src}`);
return (
<Figure>
<img src={image} alt={alt} />
{caption && <Figcaption>{caption}</Figcaption>}
</Figure>
);
};
export default Image;
Image.propTypes = {
src: PropTypes.string.isRequired,
alt: PropTypes.string.isRequired,
title: PropTypes.string,
};
Image.defaultProps = {
title: '',
}