Skip to content

Commit 8e7d281

Browse files
authored
Remove styled-components (closes #56) (#113)
* Remove styled components (closes #56) * Update storybook * Fix and document tests * Fix linting errors (#113) * Update yarn lock * ColorButton: set default values
1 parent 9ffc32d commit 8e7d281

21 files changed

+3685
-4139
lines changed

.storybook/ThemeProvider.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
1-
import React from "react";
2-
import PropTypes from "prop-types";
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
33

4-
import CssBaseline from "@material-ui/core/CssBaseline";
5-
import { MuiThemeProvider } from "@material-ui/core/styles";
6-
import { StylesProvider } from "@material-ui/styles";
7-
8-
import { ThemeProvider as StyledThemeProvider } from "styled-components";
4+
import CssBaseline from '@material-ui/core/CssBaseline';
5+
import { ThemeProvider as StyledThemeProvider } from '@material-ui/core/styles';
6+
import { StylesProvider } from '@material-ui/styles';
7+
import { createMuiTheme } from '@material-ui/core';
98

109
const ThemeProvider = ({ theme, children }) => {
11-
const nextTheme = Object.assign({}, theme);
10+
const { locale, ...options } = theme;
11+
const nextTheme = createMuiTheme(options, locale);
1212

1313
return (
1414
<StylesProvider injectFirst>
1515
<StyledThemeProvider theme={nextTheme}>
16-
<MuiThemeProvider theme={nextTheme}>
17-
<CssBaseline />
18-
{children}
19-
</MuiThemeProvider>
16+
<CssBaseline />
17+
{children}
2018
</StyledThemeProvider>
2119
</StylesProvider>
2220
);
2321
};
2422

2523
ThemeProvider.propTypes = {
2624
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
27-
theme: PropTypes.object.isRequired
25+
theme: PropTypes.object.isRequired,
2826
};
2927

3028
export default ThemeProvider;

.storybook/darkTheme.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import { createMuiTheme } from "@material-ui/core/styles";
2-
3-
const darkTheme = createMuiTheme({
1+
const darkTheme = {
42
name: 'Dark Theme',
53
palette: {
64
type: 'dark',
75
},
8-
});
6+
};
97

108
export default darkTheme;

.storybook/frenchTheme.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { createMuiTheme } from "@material-ui/core/styles";
21
import { frFR } from '@material-ui/core/locale';
32

4-
const frenchTheme = createMuiTheme({
3+
const frenchTheme = {
54
name: 'Dark French Theme',
65
palette: {
76
type: 'dark',
87
},
9-
}, frFR);
8+
locale: frFR,
9+
};
1010

1111
export default frenchTheme;

.storybook/lightTheme.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import { createMuiTheme } from "@material-ui/core/styles";
2-
3-
const lightTheme = createMuiTheme({
1+
const lightTheme = {
42
name: 'Light Theme',
53
palette: {
64
type: 'light',
75
},
8-
});
6+
};
97

108
export default lightTheme;

.storybook/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
22
stories: ['../stories/**/*.stories.(js|mdx)'],
3-
addons: ['@storybook/addon-actions', '@storybook/addon-links', 'storybook-addon-styled-component-theme', '@storybook/addon-docs'],
3+
addons: ['@storybook/addon-actions', '@storybook/addon-links', '@storybook/addon-docs', '@react-theming/storybook-addon'],
44
};

.storybook/manager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { addons } from '@storybook/addons';
22
import '@storybook/addon-actions/register';
33
import '@storybook/addon-links/register';
4-
import 'storybook-addon-styled-component-theme/dist/register';
4+
import '@react-theming/storybook-addon';
55
import muiccTheme from './muiccTheme';
66

77
addons.setConfig({

.storybook/preview.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { addParameters } from '@storybook/react';
33
import { DocsPage, DocsContainer } from '@storybook/addon-docs/blocks';
44
import { addDecorator } from '@storybook/react';
55
import { withKnobs } from "@storybook/addon-knobs";
6-
import { withThemesProvider } from 'storybook-addon-styled-component-theme';
6+
import { withThemes } from '@react-theming/storybook-addon/dist/preview';
77
import ThemeProvider from './ThemeProvider';
88
import lightTheme from './lightTheme';
99
import darkTheme from './darkTheme';
1010
import frenchTheme from './frenchTheme';
1111

1212
const themes = [lightTheme, darkTheme, frenchTheme];
13-
addDecorator(withThemesProvider(themes, ThemeProvider));
13+
addDecorator(withThemes(ThemeProvider, themes));
1414
addDecorator(withKnobs);
1515
addDecorator(storyFn => <div style={{ padding: '48px' }}>{storyFn()}</div>);
1616
addParameters({

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
## Why another ColorPicker ?
4848

4949
- Fully compatible with Material-UI : theming and low level components
50-
- Styled with `styled-components`
5150
- Highly customizable ColorPicker : gradient picker, palette, input format, deferred mode
5251
- Small in size (<30kb) without any direct dependencies
5352
- Use modern React hook and coding conventions
@@ -67,7 +66,7 @@ https://mikbry.github.io/material-ui-color/
6766

6867
## Requirements
6968
- Works on modern browsers supporting ES6+ (Not compatible with IE)
70-
- React, Styled-Component and Material-UI frameworks
69+
- React and Material-UI frameworks
7170

7271
## Install
7372

@@ -90,7 +89,6 @@ you need to have in your dependencies:
9089
"prop-types": "^15.7.2",
9190
"react": "^17.0.1",
9291
"react-dom": "^17.0.1",
93-
"styled-components": "^5.2.1"
9492
```
9593

9694
`material-ui-color` bring 5 components.

package.json

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,18 @@
4141
"@commitlint/cli": "^8.3.5",
4242
"@commitlint/config-conventional": "^8.3.4",
4343
"@material-ui/core": "^4.11.2",
44+
"@react-theming/storybook-addon": "^1.0.3",
4445
"@rollup/plugin-node-resolve": "^7.1.1",
4546
"@rollup/plugin-replace": "^2.3.1",
4647
"@rollup/plugin-url": "^4.0.2",
47-
"@storybook/addon-actions": "^5.2.6",
48-
"@storybook/addon-docs": "^5.3.18",
49-
"@storybook/addon-knobs": "^5.3.18",
50-
"@storybook/addon-links": "^5.2.6",
51-
"@storybook/addons": "^5.2.6",
52-
"@storybook/react": "^5.2.6",
53-
"@testing-library/jest-dom": "^5.3.0",
54-
"@testing-library/react": "^10.0.1",
48+
"@storybook/addon-actions": "^6.1.21",
49+
"@storybook/addon-docs": "^6.1.21",
50+
"@storybook/addon-knobs": "^6.1.21",
51+
"@storybook/addon-links": "^6.1.21",
52+
"@storybook/addons": "^6.1.21",
53+
"@storybook/react": "^6.1.21",
54+
"@testing-library/jest-dom": "^5.11.9",
55+
"@testing-library/react": "^11.2.5",
5556
"babel-jest": "^25.1.0",
5657
"babel-loader": "^8.0.6",
5758
"cross-env": "^7.0.0",
@@ -65,9 +66,8 @@
6566
"eslint-plugin-react": "^7.18.3",
6667
"eslint-plugin-react-hooks": "^2.3.0",
6768
"husky": "^5.1.3",
68-
"jest": "^25.1.0",
69+
"jest": "^26.6.3",
6970
"jest-css-modules": "^2.1.0",
70-
"jest-styled-components": "^7.0.0",
7171
"material-ui-popup-state": "^1.7.1",
7272
"packito": "^0.5.0",
7373
"prettier": "^1.19.1",
@@ -82,9 +82,7 @@
8282
"rollup-plugin-hot-css": "^0.0.6",
8383
"rollup-plugin-react-refresh": "^0.0.1",
8484
"rollup-plugin-string": "^3.0.0",
85-
"rollup-plugin-terser": "^5.2.0",
86-
"storybook-addon-styled-component-theme": "^1.3.0",
87-
"styled-components": "^5.2.1"
85+
"rollup-plugin-terser": "^5.2.0"
8886
},
8987
"husky": {
9088
"hooks": {
@@ -102,8 +100,7 @@
102100
"material-ui-popup-state": "^1.5.3",
103101
"prop-types": "^15.7.2",
104102
"react": "^16.12.0",
105-
"react-dom": "^16.12.0",
106-
"styled-components": "^5.0.1"
103+
"react-dom": "^16.12.0"
107104
},
108105
"dependencies": {},
109106
"jest": {

rollup.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export default {
2424
'prop-types',
2525
'react-is',
2626
'hoist-non-react-statics',
27-
'styled-components',
2827
'Element',
2928
],
3029
output: [

0 commit comments

Comments
 (0)