Skip to content

Instantly share code, notes, and snippets.

function Button({ type, children }) {
return <button type={type}>{children}</button>;
}
@lvarayut
lvarayut / App.js
Created April 17, 2017 15:29
Step-7 Reuse style with "css"
import React, { Component } from 'react';
import styled, { css } from 'styled-components';
...
const border = css`
${props => {
if (props.showBorder) {
return `
border: 1px solid ${mainColor};
@lvarayut
lvarayut / App.js
Last active April 20, 2017 09:07
Step-6 Optional thumbnail border
...
const Thumbnail = styled.img`
flex-grow: 1;
width: 300px;
height: 250px;
padding: 5px;
margin: 15px;
${props => {
if (props.showBorder) {
@lvarayut
lvarayut / App.js
Last active April 20, 2017 09:05
Step-5 Gallery and Thumbnail components
...
const Gallery = styled.div`
display: flex;
flex-wrap: wrap;
`;
const Thumbnail = styled.img`
flex-grow: 1;
width: 300px;
@lvarayut
lvarayut / index.js
Created April 17, 2017 14:23
Step-4 Global style
import React from 'react';
import ReactDOM from 'react-dom';
import { injectGlobal } from 'styled-components';
import App from './App';
ReactDOM.render(
<App />,
document.getElementById('root')
);
@lvarayut
lvarayut / App.js
Last active April 17, 2017 15:16
Step-3 Style component
import React, { Component } from 'react';
import styled from 'styled-components';
const mainColor = 'indianred'
const Title = styled.h1`
color: ${props => props.color || 'goldenrod'};
font-size: 2.8em;
margin: 25px;
padding-bottom: 20px;
@lvarayut
lvarayut / App.js
Last active April 17, 2017 15:11
Step-2 Use prop to set Title color
import React, { Component } from 'react';
import styled from 'styled-components';
const mainColor = 'indianred'
const Title = styled.h1`
color: ${props => props.color || 'goldenrod'}
`;
class App extends Component {
@lvarayut
lvarayut / App.js
Last active April 17, 2017 15:11
Step-1 Create Title component
import React, { Component } from 'react';
import styled from 'styled-components';
const Title = styled.h1`
color: goldenrod;
`;
class App extends Component {
render() {
return (
@lvarayut
lvarayut / instructions.md
Last active November 12, 2015 03:50
SSH to a VirtualBox guest

On Mac (Host)

VBoxManage modifyvm <VM-Name> --natpf1 "ssh,tcp,,3022,,22"

On Ubuntu (Guest)

sudo apt-get install openssh-server