Created
February 10, 2019 09:27
-
-
Save carlrip/403a060747810630a5a03f85b2607530 to your computer and use it in GitHub Desktop.
Playing with styled components - separating
This file contains hidden or 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
| const Container = styled.div` | |
| width: 400px; | |
| margin: 30px auto; | |
| font-family: ${fontFamily}; | |
| font-size: ${fontSize}; | |
| color: ${gray2}; | |
| `; | |
| const List = styled.ul` | |
| list-style: none; | |
| padding: 0px 20px; | |
| background-color: #fff; | |
| border-bottom-left-radius: 4px; | |
| border-bottom-right-radius: 4px; | |
| border-top: 3px solid ${accent1}; | |
| box-shadow: 0 3px 5px 0 rgba(0, 0, 0, 0.16); | |
| `; | |
| const ListItem = styled.li` | |
| display: flex; | |
| flex-direction: column; | |
| padding: 10px 0px; | |
| border-top: 1px solid ${gray5}; | |
| :first-child { | |
| border-top: none; | |
| } | |
| `; | |
| const Title = styled.span` | |
| font-size: 18px; | |
| color: ${gray1}; | |
| margin-bottom: 5px; | |
| `; | |
| const App = () => ( | |
| <Container> | |
| <List> | |
| {posts.map(({ id, title, body }) => ( | |
| <ListItem key={id}> | |
| <Title>{title}</Title> | |
| <span>{body}</span> | |
| </ListItem> | |
| ))} | |
| </List> | |
| </Container>; | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment