diff options
author | Nick Van Doorn <vandoorn.nick@gmail.com> | 2019-03-19 02:27:10 -0700 |
---|---|---|
committer | Nick Van Doorn <vandoorn.nick@gmail.com> | 2019-03-19 02:27:10 -0700 |
commit | 09eea921546d98d31da53a60d25df2e68ed56efb (patch) | |
tree | cd92e51b3b1fe17f6d0c5f4d7adc963c2dababe8 | |
parent | 68a82719bf3c80e189fe3ae55aa0f76e6934c160 (diff) |
Abstract away image caption, style, & link
-rw-r--r-- | src/components/image.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/components/image.js b/src/components/image.js new file mode 100644 index 0000000..df5ddb3 --- /dev/null +++ b/src/components/image.js @@ -0,0 +1,30 @@ +import React from 'react' +import { css } from '@emotion/core' +import { margins } from './globals' + +const imgContainerStyle = css` + text-align: right; + & a { + border-bottom: none; + } +` + +export const Image = ({ imgUrl, caption, noShadow }) => { + const imgStyle = css` + max-height: 300px; + align-self: flex-end; + ${!noShadow + ? `box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);` + : ''} + 0 15px 12px rgba(0, 0, 0, 0.22); + margin-bottom: ${margins.md}px; + ` + return ( + <div css={imgContainerStyle}> + <a href={imgUrl} target="_blank" rel="noopener noreferrer"> + <img css={imgStyle} src={imgUrl} alt={caption} /> + </a> + <figcaption>{caption}</figcaption> + </div> + ) +} |