Skip to content

Commit

Permalink
Merge branch 'redux' into universal-redux
Browse files Browse the repository at this point in the history
  • Loading branch information
diegohaz committed Jan 3, 2017
2 parents b06e9a0 + 907665b commit 1c7fc6c
Show file tree
Hide file tree
Showing 51 changed files with 189 additions and 1,240 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"webpack-dev-server": "^1.16.2"
},
"dependencies": {
"arc-theme": "^0.2.1",
"axios": "^0.15.2",
"babel-cli": "^6.18.0",
"babel-core": "^6.17.0",
Expand Down Expand Up @@ -87,7 +88,7 @@
"redux-saga": "^0.14.0",
"redux-thunk": "^2.1.0",
"serialize-javascript": "^1.3.0",
"styled-components": "1.1.1",
"styled-components": "^1.2.1",
"url-loader": "^0.5.7",
"validator": "^6.1.0",
"webpack": "^1.13.2",
Expand Down
20 changes: 0 additions & 20 deletions src-clean/components/globals.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { PropTypes, Component } from 'react'
import { injectGlobal, ThemeProvider } from 'styled-components'
import Helmet from 'react-helmet'

import theme from './theme'
import theme from './themes/default'

injectGlobal`
body {
Expand Down
23 changes: 4 additions & 19 deletions src/components/atoms/Atom/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { PropTypes } from 'react'
import styled from 'styled-components'

export const fontFamily = ({ theme }) => theme.fonts.primary

export const color = ({ theme, reverse, color }) =>
theme[reverse ? 'reverseColors' : 'colors'][color][color === 'grayscale' ? 0 : 1]
import { font, color } from 'arc-theme'

const Atom = styled.span`
font-family: ${fontFamily};
color: ${color};
font-family: ${font('primary')};
color: ${color({ grayscale: 0 }, 1)};
`

Atom.propTypes = {
Expand All @@ -17,18 +13,7 @@ Atom.propTypes = {
}

Atom.defaultProps = {
color: 'grayscale',
theme: {
fonts: {
primary: 'sans-serif'
},
colors: {
grayscale: { 0: '#222' }
},
reverseColors: {
grayscale: { 0: '#fff' }
}
}
color: 'grayscale'
}

export default Atom
33 changes: 1 addition & 32 deletions src/components/atoms/Atom/index.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { shallow } from 'enzyme'
import Atom, * as styles from '.'
import Atom from '.'

const wrap = (props = {}) => shallow(<Atom {...props} />)

Expand All @@ -13,34 +13,3 @@ it('renders props when passed in', () => {
const wrapper = wrap({ id: 'foo' })
expect(wrapper.find({ id: 'foo' })).toHaveLength(1)
})

describe('styles', () => {
const theme = {
fonts: {
primary: 'sans-serif'
},
colors: {
grayscale: { 0: '#222' },
primary: { 1: 'red' }
},
reverseColors: {
grayscale: { 0: '#fff' },
primary: { 1: 'blue' }
}
}

test('fontFamily', () => {
expect(styles.fontFamily({ theme })).toBe(theme.fonts.primary)
})

test('color', () => {
const props = {
color: 'grayscale',
reverse: false,
theme
}
expect(styles.color(props)).toBe(theme.colors.grayscale[0])
expect(styles.color({ ...props, reverse: true })).toBe(theme.reverseColors.grayscale[0])
expect(styles.color({ ...props, color: 'primary' })).toBe(theme.colors.primary[1])
})
})
30 changes: 5 additions & 25 deletions src/components/atoms/Badge/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
import { PropTypes } from 'react'
import styled from 'styled-components'

export const fontFamily = ({ theme }) => theme.fonts.primary

export const color = ({ reverse, theme }) =>
reverse ? theme.colors.grayscale[0] : theme.reverseColors.grayscale[0]

export const backgroundColor = ({ reverse, theme, color }) =>
theme[reverse ? 'reverseColors' : 'colors'][color][1]
import { font, color, reverseColor } from 'arc-theme'

const Badge = styled.span`
font-family: ${fontFamily};
font-family: ${font('primary')};
font-size: 0.75rem;
line-height: 1.5em;
padding: 0 0.3em;
color: ${color};
background-color: ${backgroundColor};
color: ${reverseColor('grayscale', 0)};
background-color: ${color(1)};
border-radius: 0.16667em;
`

Expand All @@ -25,20 +18,7 @@ Badge.propTypes = {
}

Badge.defaultProps = {
color: 'primary',
theme: {
fonts: {
primary: 'sans-serif'
},
colors: {
grayscale: { 0: '#222', 1: '#555' },
primary: { 1: '#2196f3' }
},
reverseColors: {
grayscale: { 0: '#fff', 1: '#bbb' },
primary: { 1: '#71bcf7' }
}
}
color: 'primary'
}

export default Badge
37 changes: 1 addition & 36 deletions src/components/atoms/Badge/index.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { shallow } from 'enzyme'
import Badge, * as styles from '.'
import Badge from '.'

const wrap = (props = {}) => shallow(<Badge {...props} />)

Expand All @@ -13,38 +13,3 @@ it('renders props when passed in', () => {
const wrapper = wrap({ id: 'foo' })
expect(wrapper.find({ id: 'foo' })).toHaveLength(1)
})

describe('styles', () => {
const theme = {
fonts: {
primary: 'sans-serif'
},
colors: {
grayscale: { 0: '#222', 1: '#555' },
primary: { 1: '#2196f3' }
},
reverseColors: {
grayscale: { 0: '#fff', 1: '#bbb' },
primary: { 1: '#71bcf7' }
}
}

test('fontFamily', () => {
expect(styles.fontFamily({ theme })).toBe(theme.fonts.primary)
})

test('color', () => {
expect(styles.color({ theme, reverse: false })).toBe(theme.reverseColors.grayscale[0])
expect(styles.color({ theme, reverse: true })).toBe(theme.colors.grayscale[0])
})

test('backgroundColor', () => {
const props = {
color: 'primary',
reverse: false,
theme
}
expect(styles.backgroundColor(props)).toBe(theme.colors.primary[1])
expect(styles.backgroundColor({ ...props, reverse: true })).toBe(theme.reverseColors.primary[1])
})
})
28 changes: 5 additions & 23 deletions src/components/atoms/Block/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import { PropTypes } from 'react'
import styled from 'styled-components'

export const fontFamily = ({ theme }) => theme.fonts.primary

export const backgroundColor = ({ theme, reverse, color, transparent }) =>
transparent ? 'transparent' : theme[reverse ? 'colors' : 'reverseColors'][color][0]

export const color = ({ theme, reverse, color }) =>
theme[reverse ? 'reverseColors' : 'colors'][color][color === 'grayscale' ? 0 : 1]
import { font, color, reverseColor, ifProps } from 'arc-theme'

const Block = styled.div`
font-family: ${fontFamily};
background-color: ${backgroundColor};
color: ${color};
font-family: ${font('primary')};
background-color: ${ifProps('transparent', 'transparent', reverseColor(0))};
color: ${color({ grayscale: 0 }, 1)};
`

Block.propTypes = {
Expand All @@ -21,18 +14,7 @@ Block.propTypes = {
}

Block.defaultProps = {
color: 'grayscale',
theme: {
fonts: {
primary: 'sans-serif'
},
colors: {
grayscale: { 0: '#222' }
},
reverseColors: {
grayscale: { 0: '#fff' }
}
}
color: 'grayscale'
}

export default Block
46 changes: 1 addition & 45 deletions src/components/atoms/Block/index.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { shallow } from 'enzyme'
import Block, * as styles from '.'
import Block from '.'

const wrap = (props = {}) => shallow(<Block {...props} />)

Expand All @@ -13,47 +13,3 @@ it('renders props when passed in', () => {
const wrapper = wrap({ id: 'foo' })
expect(wrapper.find({ id: 'foo' })).toHaveLength(1)
})

describe('styles', () => {
const theme = {
fonts: {
primary: 'sans-serif'
},
colors: {
grayscale: { 0: '#222' },
primary: { 0: 'darkred', 1: 'red' }
},
reverseColors: {
grayscale: { 0: '#fff' },
primary: { 0: 'lightblue', 1: 'blue' }
}
}

test('fontFamily', () => {
expect(styles.fontFamily({ theme })).toBe(theme.fonts.primary)
})

test('backgroundColor', () => {
const props = {
color: 'grayscale',
reverse: false,
theme
}
expect(styles.backgroundColor(props)).toBe(theme.reverseColors.grayscale[0])
expect(styles.backgroundColor({ ...props, transparent: true })).toBe('transparent')
expect(styles.backgroundColor({ ...props, reverse: true })).toBe(theme.colors.grayscale[0])
expect(styles.backgroundColor({ ...props, color: 'primary' }))
.toBe(theme.reverseColors.primary[0])
})

test('color', () => {
const props = {
color: 'grayscale',
reverse: false,
theme
}
expect(styles.color(props)).toBe(theme.colors.grayscale[0])
expect(styles.color({ ...props, reverse: true })).toBe(theme.reverseColors.grayscale[0])
expect(styles.color({ ...props, color: 'primary' })).toBe(theme.colors.primary[1])
})
})
Loading

0 comments on commit 1c7fc6c

Please sign in to comment.