Kirill Novikov, Solidopinion Inc.
Brought to you by © Kirill Novikov
*2014 year Christopher Chedeau aka vjeux (React: CSS in JS)
const style = {
color: 'white',
backgroundColor: 'black',
}
const Button = () => <button style={style}>Click me!</button>
<button style="color: white; background-color: black;">Click me!</button>
const style = {
color: 'white',
backgroundColor: 'black',
':hover': {
backgroundColor: 'red'
},
'@media (min-width: 992px)': {
padding: '0.6em 1.2em'
}
}
const Button = () => <button style={style}>Click me!</button>
.button {
background-color: #white;
border-radius: 5px;
}
import styles from './index.css'
const Button = () => (<button className={styles.button}>Click me!</button>)
<button class="_2wpxM3yizfwbWee6k0UlD4">Click me!</button>
import styled from 'styled-components';
const Button = styled.button`
border-radius: 3px;
color: white;
&:hover: {
color: red;
}
`
render(<Button value="Click me!" />)
<style>._2wpxM3yizfwbWee6k0UlD4 { border-radius: 3px; color: white; }</style>
<button class="_2wpxM3yizfwbWee6k0UlD4">Click me!</button>
const a = 5
const b = 10
function tag(strings, ...values) {
console.log(strings[0]) // "Hello "
console.log(strings[1]) // " world "
console.log(values[0]) // 15
console.log(values[1]) // 50
return "Bazinga!"
}
tag`Hello ${ a + b } world ${ a * b}`
// "Bazinga!"
const Input = styled.input`
margin: 0.5em;
color: palevioletred;
`
render(
<div>
<Input placeholder="Login" type="text" onClick={ onClick } />
<Input value="@kirill3333" type="text" onClick={ onClick } />
</div>
)
const Link = ({ className, children }) => (
<a className={className}>{children}</a>
)
const StyledLink = styled(Link)`
color: palevioletred;
font-weight: bold;
`
render(
<div>
<Link>Unstyled, boring Link</Link>
<StyledLink>Styled, exciting Link</StyledLink>
</div>
)
const Button = styled.button`
background: ${props => props.primary ? 'palevioletred' : 'white'};
color: ${props => props.primary ? 'white' : 'palevioletred'};
font-size: 1em;
'
render(
<div>
<Button>Normal</Button>
<Button primary>Primary</Button>
</div>
)
const Button = styled.button`
color: palevioletred;
font-size: 1em;
'
const TomatoButton = Button.extend`
color: tomato;
'
render(
<div>
<Button>Normal Button</Button>
<TomatoButton>Tomato Button</TomatoButton>
</div>
)
import styled, { keyframes } from 'styled-components'
const rotate360 = keyframes`
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
'
const Rotate = styled.div`
animation: ${rotate360} 2s linear infinite;
'
render(
<Rotate>⌛️</Rotate>
)