Skip to content

Commit 886719a

Browse files
authored
feat(ThemeProvider): add material theme
close #80
1 parent 314ef06 commit 886719a

File tree

66 files changed

+9546
-8963
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+9546
-8963
lines changed

.styleguide/components/ReactExample.jsx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ import splitExampleCode from 'react-styleguidist/lib/utils/splitExampleCode';
77
import ThemeProvider from 'src/components/ThemeProvider';
88
import greenTheme from 'src/components/ThemeProvider/green';
99
import oceanTheme from 'src/components/ThemeProvider/ocean';
10-
import materialTheme from 'src/components/ThemeProvider/material';
10+
import generateMaterialTheme from 'src/components/ThemeProvider/material';
11+
12+
const materialTheme = generateMaterialTheme({
13+
colorList: {
14+
primary: '#3555f6'
15+
}
16+
});
1117

1218
/* eslint-disable no-invalid-this, react/no-multi-comp */
1319

@@ -46,7 +52,7 @@ export const themeColor = {
4652
material: '#415bf5'
4753
};
4854

49-
let currentThemeType = 'green';
55+
let currentThemeType = 'blue';
5056
export const changeTheme = themeType => {
5157
currentThemeType = themeType;
5258
_.each(themeListeners, listener => {
@@ -123,17 +129,21 @@ export default class ReactExample extends Component {
123129
if (!compiledCode) {
124130
return null;
125131
}
126-
127132
const { head, example } = splitExampleCode(compiledCode);
128133
const initialState = this.getExampleInitialState(head);
129134
const exampleComponent = this.getExampleComponent(example);
130-
const wrappedComponent = (
131-
<ThemeProvider theme={themeList[this.state.theme]}>
135+
const wrappedComponent =
136+
this.state.theme === 'blue' ? (
132137
<Wrapper onError={this.props.onError}>
133138
<StateHolder component={exampleComponent} initialState={initialState} />
134139
</Wrapper>
135-
</ThemeProvider>
136-
);
140+
) : (
141+
<ThemeProvider theme={themeList[this.state.theme]}>
142+
<Wrapper onError={this.props.onError}>
143+
<StateHolder component={exampleComponent} initialState={initialState} />
144+
</Wrapper>
145+
</ThemeProvider>
146+
);
137147
return wrappedComponent;
138148
}
139149
}

.styleguide/components/StyleGuideRenderer.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ const styles = ({
8585
},
8686
themeButton: {
8787
display: 'inline-block',
88+
cursor: 'pointer',
8889
width: '4em',
8990
height: '4em',
9091
borderRadius: '2em',

.styleguide/setup.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ global.PropTypes = require('prop-types');
1111
global.ReactDOM = require('react-dom');
1212

1313
global.moment = require('moment');
14+
15+
import generateMaterialTheme from 'src/components/ThemeProvider/material';
16+
17+
global.generateMaterialTheme = generateMaterialTheme;

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"babel-jest": "^22.4.3",
7777
"babel-loader": "^7.1.4",
7878
"babel-plugin-lodash": "^3.3.2",
79-
"babel-plugin-styled-components": "^1.5.1",
79+
"babel-plugin-styled-components": "^1.10.0",
8080
"babel-plugin-transform-class-properties": "^6.24.1",
8181
"babel-plugin-transform-decorators-legacy": "^1.3.4",
8282
"babel-plugin-webpack-alias": "^2.1.2",
@@ -94,7 +94,7 @@
9494
"file-loader": "^1.1.11",
9595
"husky": "^0.14.3",
9696
"jest": "^22.4.3",
97-
"jest-styled-components": "^5.0.1",
97+
"jest-styled-components": "^6.3.1",
9898
"lint-staged": "^7.0.4",
9999
"mini-css-extract-plugin": "^0.4.0",
100100
"moment-timezone": "^0.5.21",
@@ -107,10 +107,10 @@
107107
"react-test-renderer": "^15",
108108
"standard-version": "^4.4.0",
109109
"style-loader": "^0.20.3",
110-
"stylelint": "^9.4.0",
110+
"stylelint": "^9.9.0",
111111
"stylelint-config-recommended": "^2.1.0",
112112
"stylelint-config-styled-components": "^0.1.1",
113-
"stylelint-processor-styled-components": "^1.3.2",
113+
"stylelint-processor-styled-components": "^1.5.1",
114114
"url-loader": "^1.0.1",
115115
"webpack": "^4.5.0",
116116
"webpack-cli": "^2.0.14"

0 commit comments

Comments
 (0)