Skip to content

Instantly share code, notes, and snippets.

@tfiechowski
Last active October 29, 2019 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tfiechowski/4a43c4242d28ae55cb3a38ba0f84ab40 to your computer and use it in GitHub Desktop.
Save tfiechowski/4a43c4242d28ae55cb3a38ba0f84ab40 to your computer and use it in GitHub Desktop.
import React from "react";
import styled from "styled-components";
export const Grid = styled.div`
width: 600px;
display: flex;
justify-content: start;
flex-wrap: wrap;
`;
export const GridImage = styled.div`
flex-grow: 1;
border: 1px solid white;
display: flex;
justify-content: center;
align-items: center;
background-image: ${props => `url("${props.src}")`};
background-size: cover;
background-position: 50%;
`;
const GridItemWrapper = styled.div`
flex: 0 0 33.3%;
display: flex;
justify-content: center;
align-items: stretch;
box-sizing: border-box;
:before {
content: "";
display: table;
padding-top: 100%;
}
`;
export const GridItem = ({ forwardedRef, ...props }) => (
<GridItemWrapper ref={forwardedRef} {...props} />
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment