Skip to content

Instantly share code, notes, and snippets.

@mhauken
Last active November 21, 2019 15:14
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 mhauken/2a60829581ab062678eb04c3af93f32b to your computer and use it in GitHub Desktop.
Save mhauken/2a60829581ab062678eb04c3af93f32b to your computer and use it in GitHub Desktop.
Modulus example
import React from "react"
import styled from "styled-components"
const anArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
const colorArray = ["#D8CFAC", "#F8F2D3", "#FFAB00", "#62796C", "#DAE0DC"]
const ModulusExample = () => (
<Wrapper>
{anArray.map((item, index) => (
<Example key={item} color={colorArray[index % colorArray.length]}>
{item}
</Example>
))}
</Wrapper>
)
const Wrapper = styled.div`
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-column-gap: 24px;
grid-row-gap: 24px;
`
const Example = styled.div`
min-height: 135px;
background-color: ${p => p.color};
padding: 12px;
`
export default ModulusExample
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment