Created
April 17, 2017 15:29
-
-
Save lvarayut/7886f9f64e0321efc645566b36addd9c to your computer and use it in GitHub Desktop.
Step-7 Reuse style with "css"
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
import React, { Component } from 'react'; | |
import styled, { css } from 'styled-components'; | |
... | |
const border = css` | |
${props => { | |
if (props.showBorder) { | |
return ` | |
border: 1px solid ${mainColor}; | |
border-radius: 8px; | |
`; | |
} | |
}} | |
`; | |
const Thumbnail = styled.img` | |
flex-grow: 1; | |
width: 300px; | |
height: 250px; | |
padding: 5px; | |
margin: 15px; | |
${border} | |
`; | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment