Last active
November 21, 2019 15:14
-
-
Save mhauken/2a60829581ab062678eb04c3af93f32b to your computer and use it in GitHub Desktop.
Modulus example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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