Skip to content

Commit d4308c6

Browse files
authored
Rename theme to 'circuit' (#165)
* Rename theme file * Fix theme usage * Rename theme to 'circuit'
1 parent 17d8bd7 commit d4308c6

File tree

12 files changed

+42
-38
lines changed

12 files changed

+42
-38
lines changed

.storybook/config.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { withKnobs } from '@storybook/addon-knobs';
55
import { setOptions } from '@storybook/addon-options';
66
import { ThemeProvider } from 'emotion-theming';
77

8-
import { standard } from '../src/themes';
8+
import { circuit } from '../src/themes';
99
import injectGlobalStyles from '../src/styles/global-styles';
1010

1111
// Dynamically decide wich styles to load.
@@ -14,7 +14,7 @@ if (PRODUCTION) {
1414
}
1515

1616
if (!PRODUCTION) {
17-
injectGlobalStyles({ theme: standard });
17+
injectGlobalStyles({ theme: circuit });
1818
}
1919

2020
// Sets the info addon's options.
@@ -32,7 +32,7 @@ setOptions({
3232
const req = require.context('../src/components', true, /\.story\.js$/);
3333

3434
const withThemeProvider = storyFn => (
35-
<ThemeProvider theme={standard}>{storyFn()}</ThemeProvider>
35+
<ThemeProvider theme={circuit}>{storyFn()}</ThemeProvider>
3636
);
3737

3838
const withStoryStyles = storyFn => {

build/global-styles

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ require('babel-register');
33

44
const { format } = require('prettier');
55

6-
const { standard } = require('../src/themes');
6+
const { circuit } = require('../src/themes');
77
const { createGlobalStyles } = require('../src/styles/global-styles');
88

9-
const globalStyles = createGlobalStyles({ theme: standard });
9+
const globalStyles = createGlobalStyles({ theme: circuit });
1010
console.log(format(globalStyles, { parser: 'css' }));

build/stylesheet/lib/extract-styles.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@ import * as emotion from 'react-emotion';
33
import * as ReactTestRenderer from 'react-test-renderer';
44
import { ThemeProvider } from 'emotion-theming';
55

6-
import { standard } from '../../../src/themes';
6+
import { circuit } from '../../../src/themes';
77

88
const adjustPath = path => `../../../${path}`;
99

1010
const renderComponent = async (Component, theme, props) => {
1111
try {
1212
ReactTestRenderer.create(
13-
<ThemeProvider theme={standard}>
13+
<ThemeProvider theme={circuit}>
1414
<Component {...{ theme, ...props }} />
1515
</ThemeProvider>
1616
);
17+
// eslint-disable-next-line no-empty
1718
} catch (e) {}
1819
};
1920

@@ -75,7 +76,7 @@ const extractStyles = async ({ path, propTypes }) => {
7576
const relativePath = adjustPath(path);
7677
const { default: Component } = await import(relativePath);
7778
const propGroups = createPropGroups(propTypes);
78-
propGroups.forEach(props => renderComponent(Component, standard, props));
79+
propGroups.forEach(props => renderComponent(Component, circuit, props));
7980
const { inserted } = emotion.caches;
8081
const regex = /-/;
8182
const filteredStyles = Object.entries(inserted).reduce(

jest.setup.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ import { create } from 'react-test-renderer';
99
import * as emotion from 'emotion';
1010
import { ThemeProvider } from 'emotion-theming';
1111

12-
import { standard } from './src/themes';
12+
import { circuit } from './src/themes';
1313

1414
Enzyme.configure({ adapter: new Adapter() });
1515

1616
const renderWithTheme = renderFn => (component, ...rest) =>
17-
renderFn(<ThemeProvider theme={standard}>{component}</ThemeProvider>, rest);
17+
renderFn(<ThemeProvider theme={circuit}>{component}</ThemeProvider>, rest);
1818

1919
const shallowWithTheme = tree => {
20-
const context = shallow(<ThemeProvider theme={standard} />)
20+
const context = shallow(<ThemeProvider theme={circuit} />)
2121
.instance()
2222
.getChildContext();
2323
return shallow(tree, { context });
2424
};
2525

2626
const mountWithTheme = tree => {
27-
const context = shallow(<ThemeProvider theme={standard} />)
27+
const context = shallow(<ThemeProvider theme={circuit} />)
2828
.instance()
2929
.getChildContext();
3030

src/components/AutoCompleteInput/AutoCompleteInput.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import styled, { css } from 'react-emotion';
44
import Downshift from 'downshift';
55
import { includes } from 'lodash/fp';
66

7-
import { zIndex } from '../../themes/default';
87
import SearchInput from '../SearchInput';
98
import Card from '../Card';
109
import { textMega } from '../../styles/style-helpers';
@@ -18,14 +17,16 @@ const AutoCompleteWrapper = styled('div')`
1817
min-width: 150px;
1918
`;
2019

21-
const ItemsWrapper = styled('div')`
20+
const baseItemsWrapperStyles = ({ theme }) => css`
2221
position: relative;
2322
height: 0px;
2423
overflow: visible;
2524
margin-top: ${props => props.theme.spacings.bit};
26-
z-index: ${zIndex.popover};
25+
z-index: ${theme.zIndex.popover};
2726
`;
2827

28+
const ItemsWrapper = styled('div')(baseItemsWrapperStyles);
29+
2930
const itemsBaseStyles = ({ theme }) => css`
3031
padding: ${theme.spacings.kilo} ${theme.spacings.mega};
3132
position: absolute;

src/components/Col/Col.story.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import { storiesOf } from '@storybook/react';
44
import { withInfo } from '@storybook/addon-info';
55
import { GROUPS } from '../../../.storybook/hierarchySeparators';
66

7-
import { standard } from '../../themes';
7+
import { circuit } from '../../themes';
88

99
import withTests from '../../util/withTests';
1010
import Col from './Col';
1111

1212
const StyledCol = styled(Col)`
13-
background-color: ${standard.colors.b500};
14-
color: ${standard.colors.white};
13+
background-color: ${circuit.colors.b500};
14+
color: ${circuit.colors.white};
1515
font-size: 14px;
1616
font-weight: bold;
1717
line-height: 20px;

src/components/CreditCardDetails/components/CardNumberInput/CardNumberInput.story.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { reduce } from '../../../../util/fp';
1010
import { CardNumberInput, cardSchemeIcons } from '..';
1111
import { schemes as cardSchemes } from '../..';
1212
import Text from '../../../Text';
13-
import { standard } from '../../../../themes';
13+
import { circuit } from '../../../../themes';
1414

1515
const { SCHEMES } = cardSchemes;
1616

@@ -34,9 +34,9 @@ const manySchemes = [
3434
const manySchemeIcons = getIconComponents(manySchemes);
3535

3636
const marginTopClassName = css`
37-
width: calc(100vw - ${standard.spacings.byte});
37+
width: calc(100vw - ${circuit.spacings.byte});
3838
39-
${standard.mq.untilKilo`
39+
${circuit.mq.untilKilo`
4040
width: 75vw;
4141
max-width: 400px;
4242
`};

src/components/Grid/Grid.story.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ import withTests from '../../util/withTests';
88
import Grid from './Grid';
99
import Col from '../Col';
1010
import Row from '../Row';
11-
import { standard } from '../../themes';
11+
import { circuit } from '../../themes';
1212

1313
const StyledCol = styled(Col)`
14-
color: ${standard.colors.white};
14+
color: ${circuit.colors.white};
1515
font-size: 14px;
1616
font-weight: bold;
1717
line-height: 20px;
1818
height: 40px;
1919
padding: 10px;
2020
&:nth-of-type(n) {
21-
background-color: ${standard.colors.b500};
21+
background-color: ${circuit.colors.b500};
2222
}
2323
2424
&:nth-of-type(2n) {
25-
background-color: ${standard.colors.b300};
25+
background-color: ${circuit.colors.b300};
2626
}
2727
`;
2828

@@ -31,7 +31,7 @@ StyledCol.defaultProps = {
3131
};
3232

3333
const StyledRow = styled(Row)`
34-
border: 2px solid ${standard.colors.y100};
34+
border: 2px solid ${circuit.colors.y100};
3535
margin-bottom: 8px;
3636
`;
3737

src/components/Popover/Popover.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import React, { Component } from 'react';
22
import PropTypes from 'prop-types';
33
import { Manager, Reference, Popper } from 'react-popper';
4-
import styled from 'react-emotion';
5-
6-
import { zIndex } from '../../themes/default';
4+
import styled, { css } from 'react-emotion';
75

86
import {
97
TOP,
@@ -22,10 +20,13 @@ const ReferenceWrapper = styled('div')`
2220
display: inline-block;
2321
`;
2422

25-
const PopoverWrapper = styled('div')`
26-
z-index: ${zIndex.popover};
23+
const basePopoverWrapperStyles = ({ theme }) => css`
24+
label: popover;
25+
z-index: ${theme.zIndex.popover};
2726
`;
2827

28+
const PopoverWrapper = styled('div')(basePopoverWrapperStyles);
29+
2930
class Popover extends Component {
3031
static TOP = TOP;
3132
static BOTTOM = BOTTOM;

src/components/Row/Row.story.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ import { GROUPS } from '../../../.storybook/hierarchySeparators';
77
import withTests from '../../util/withTests';
88
import Row from './Row';
99
import Col from '../Col';
10-
import { standard } from '../../themes';
10+
import { circuit } from '../../themes';
1111

1212
const StyledCol = styled(Col)`
13-
color: ${standard.colors.white};
13+
color: ${circuit.colors.white};
1414
font-size: 14px;
1515
font-weight: bold;
1616
line-height: 20px;
1717
height: 40px;
1818
padding: 10px;
1919
&:nth-of-type(n) {
20-
background-color: ${standard.colors.b500};
20+
background-color: ${circuit.colors.b500};
2121
}
2222
2323
&:nth-of-type(2n) {
24-
background-color: ${standard.colors.b300};
24+
background-color: ${circuit.colors.b300};
2525
}
2626
`;
2727

@@ -30,7 +30,7 @@ StyledCol.defaultProps = {
3030
};
3131

3232
const StyledRow = styled(Row)`
33-
border: 2px solid ${standard.colors.y100};
33+
border: 2px solid ${circuit.colors.y100};
3434
margin-bottom: 8px;
3535
`;
3636

File renamed without changes.

src/themes/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
import * as standard from './default';
1+
import * as circuit from './circuit';
22

3-
export { standard };
3+
export { circuit };
4+
export { circuit as standard };

0 commit comments

Comments
 (0)