Skip to content

Commit

Permalink
feat: implement image gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
moonlight-komorebi committed Jun 4, 2021
1 parent 2c97811 commit 2b43227
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
72 changes: 72 additions & 0 deletions src/components/ImageGallery/ImageGallery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import React from 'react';
import PropTypes from 'prop-types';
import { css } from '@emotion/react';

// TODO: replace with import of image, rather than grabbing one off the web
const noImagePlaceholder =
'https://socialistmodernism.com/wp-content/uploads/2017/07/placeholder-image.png';

const CreateImageBlock = (image) => {
return (
<a href={image} target="_blank" rel="noreferrer">
<img
src={image}
alt="placeholder-text"
css={css`
width: 285px;
height: 207px;
background: linear-gradient(0deg, #f3f4f4, #f3f4f4),
linear-gradient(
293.05deg,
#70d3af -73.46%,
#007e8a -24.52%,
#052a3a 69.75%
);
border: 1px solid rgba(0, 0, 0, 0.1);
box-sizing: border-box;
box-shadow: inset 0px 0px 0px 4px #ffffff;
border-radius: 4px;
padding: 3px;
margin-right: 16px;
margin-bottom: 6px;
object-fit: cover;
`}
/>
</a>
);
};

/**
* @param {Object} props
* @param {String[]} props.images - Array of images urls.
* @param {String} props.className
*/
const ImageGallery = ({ images, className }) => {
return (
<div
className={className}
css={css`
display: flex;
white-space: nowrap;
overflow-x: auto;
margin-bottom: 32px;
`}
>
{images && images.length > 0
? images.map((image) => {
return CreateImageBlock(image);
})
: CreateImageBlock(noImagePlaceholder)}
</div>
);
};

ImageGallery.propTypes = {
images: PropTypes.arrayOf(PropTypes.string),
className: PropTypes.string,
};

export default ImageGallery;
1 change: 1 addition & 0 deletions src/components/ImageGallery/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './ImageGallery';

0 comments on commit 2b43227

Please sign in to comment.