Skip to content
This repository was archived by the owner on Jun 20, 2022. It is now read-only.

Commit d311640

Browse files
authored
feat: support emotion 10 & remove hacks (#93)
BREAKING CHANGE: `OriginalComponent.withComponent(NewComponent)` is replaced by `uiAs(OriginalComponent, NewComponent)` `as={NewComponent}` is replaced by `uiAs={NewComponent}` `globalStyle()` is now replaced by `Normalize` component
1 parent f85b52d commit d311640

File tree

115 files changed

+4247
-4657
lines changed

Some content is hidden

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

115 files changed

+4247
-4657
lines changed

.eslintrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ module.exports = {
1818
'import/prefer-default-export': 'off',
1919
'import/no-extraneous-dependencies': 'off',
2020

21+
'no-plusplus': 'off',
2122
'no-return-assign': 'off',
2223
'no-param-reassign': 'off',
2324
'no-shadow': 'off',
2425
'default-case': 'off',
26+
'no-underscore-dangle': ['off', { allow: ['__smoothUI', '__scTheme'] }],
2527
},
2628
}

.github/ISSUE_TEMPLATE/bug.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Please provide a minimal repository on GitHub.
2222

2323
Issues without a reproduction link are likely to stall.
2424

25-
## Run `npx envinfo --system --binaries --npmPackages @smooth-ui/core-sc,@smooth-ui/core-em,styled-components,emotion,react-emotion --markdown --clipboard`
25+
## Run `npx envinfo --system --binaries --npmPackages @smooth-ui/core-sc,@smooth-ui/core-em,styled-components,@emotion/core,@emotion/styled,emotion-theming --markdown --clipboard`
2626

2727
Paste the results here:
2828

.github/ISSUE_TEMPLATE/regression.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Please provide a minimal repository on GitHub.
2727

2828
Issues without a reproduction link are likely to stall.
2929

30-
## Run `npx envinfo --system --binaries --npmPackages @smooth-ui/core-sc,@smooth-ui/core-em,styled-components,emotion,react-emotion --markdown --clipboard`
30+
## Run `npx envinfo --system --binaries --npmPackages @smooth-ui/core-sc,@smooth-ui/core-em,styled-components,@emotion/core,@emotion/styled,emotion-theming --markdown --clipboard`
3131

3232
Paste the results here:
3333

.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
node_modules/
22
dist/
33
package.json
4-
CHANGELOG.json
4+
CHANGELOG.md
55
.docz/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ npm install @smooth-ui/core-sc styled-components
1717
or
1818

1919
```sh
20-
npm install @smooth-ui/core-em react-emotion emotion-theming
20+
npm install @smooth-ui/core-em @emotion/core @emotion/styled emotion-theming
2121
```
2222

2323
Smooth UI is a style system / UI library for [React](https://reactjs.org/). It works with [Styled Components 💅](https://www.styled-components.com) or [Emotion 👩‍🎤](https://emotion.sh/).
File renamed without changes.

benchmarks/system.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/* eslint-disable no-console, import/no-unresolved */
2+
const Benchmark = require('benchmark')
3+
const sui = require('@smooth-ui/system')
4+
const mui = require('@material-ui/system')
5+
const sys = require('styled-system')
6+
7+
const suiSystem = sui.compose(
8+
sui.typography,
9+
sui.space,
10+
)
11+
const muiSystem = mui.compose(
12+
mui.typography,
13+
mui.spacing,
14+
)
15+
const sysSystem = sys.compose(
16+
sys.fontSize,
17+
sys.space,
18+
)
19+
20+
const suite = new Benchmark.Suite()
21+
22+
function runSui() {
23+
return suiSystem.props({
24+
p: { xs: 10, md: 20 },
25+
mt: 10,
26+
m: '20px',
27+
fontSize: 10,
28+
})
29+
}
30+
31+
function runMui() {
32+
return muiSystem({
33+
theme: {},
34+
p: { xs: 10, md: 20 },
35+
mt: 10,
36+
m: '20px',
37+
fontSize: 10,
38+
})
39+
}
40+
41+
function runSys() {
42+
return sysSystem({ p: [10, 20], mt: 10, m: '20px', fontSize: 10 })
43+
}
44+
45+
console.log('sui', runSui())
46+
console.log('mui', runMui())
47+
console.log('sys', runSys())
48+
49+
suite
50+
.add('@smooth-ui/system', runSui)
51+
.add('@material-ui/system', runMui)
52+
.add('styled-system', runSys)
53+
.on('cycle', event => {
54+
console.log(String(event.target))
55+
})
56+
.on('complete', function onComplete() {
57+
console.log(`Fastest is ${this.filter('fastest').map('name')}`)
58+
})
59+
.run({ async: true })

config/rollup.js

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,30 @@ import commonjs from 'rollup-plugin-commonjs'
66
import copy from 'rollup-plugin-cpy'
77
import { uglify } from 'rollup-plugin-uglify'
88

9-
// eslint-disable-next-line
10-
const babelConfig = require('../../.babelrc')
11-
12-
export const getRollupConfig = ({ pkg, pwd, buildName }) => {
9+
export const getRollupConfig = ({
10+
pkg,
11+
pwd,
12+
buildName,
13+
name,
14+
copyTypeScriptDefs,
15+
}) => {
1316
const SOURCE_DIR = path.resolve(pwd, 'src')
1417
const DIST_DIR = path.resolve(pwd, 'dist')
15-
const CORE_DIR = path.resolve(pwd, '../shared/core');
18+
const CORE_DIR = path.resolve(pwd, '../shared/core')
1619

1720
const baseConfig = {
1821
input: `${SOURCE_DIR}/index.js`,
1922
plugins: [
2023
babel({
21-
"exclude": "**/node_modules/**",
22-
...babelConfig
24+
exclude: 'node_modules/**',
25+
configFile: path.join(pwd, '../../babel.config.js'),
2326
}),
24-
copy({
25-
"files": `${CORE_DIR}/*.d.ts`,
26-
"dest": DIST_DIR
27-
})
27+
copyTypeScriptDefs
28+
? copy({
29+
files: `${CORE_DIR}/*.d.ts`,
30+
dest: DIST_DIR,
31+
})
32+
: null,
2833
],
2934
}
3035

@@ -34,8 +39,8 @@ export const getRollupConfig = ({ pkg, pwd, buildName }) => {
3439
format: 'es',
3540
},
3641
external: [
37-
...Object.keys(pkg.peerDependencies),
38-
...Object.keys(pkg.dependencies),
42+
...Object.keys(pkg.peerDependencies || {}),
43+
...Object.keys(pkg.dependencies || {}),
3944
'react-transition-group/Transition',
4045
],
4146
})
@@ -52,16 +57,16 @@ export const getRollupConfig = ({ pkg, pwd, buildName }) => {
5257
polished: 'polished',
5358
'prop-types': 'PropTypes',
5459
'emotion-theming': 'emotionTheming',
55-
emotion: 'emotion',
60+
'@emotion/core': 'emotion',
61+
'@emotion/styled': 'styled',
5662
react: 'React',
5763
'react-dom': 'ReactDom',
58-
'react-emotion': 'reactEmotion',
5964
'styled-components': 'styled',
6065
}
6166

6267
const umdConfig = Object.assign({}, baseConfig, {
6368
output: {
64-
name: 'smoothUI',
69+
name,
6570
file: `${DIST_DIR}/${buildName}.js`,
6671
format: 'umd',
6772
globals,
@@ -92,7 +97,7 @@ export const getRollupConfig = ({ pkg, pwd, buildName }) => {
9297
})
9398

9499
if (process.env.WATCH_MODE) {
95-
return [esConfig]
100+
return [esConfig, cjsConfig]
96101
}
97102

98103
return [esConfig, cjsConfig, umdConfig, minConfig]

docs/Compatibility.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: Compatibility
44

55
# Compatibility
66

7-
## Browser Support
7+
## Browser Support
88

99
Smooth-UI relies on [browsers supported by Styled Components](https://www.styled-components.com/docs/faqs#which-browsers-are-supported) or browsers supported by emotion (probably the same).
1010

docs/GettingStarted.mdx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Button } from '@smooth-ui/core-sc'
77

88
# Getting Started
99

10-
## Installation
10+
## Installation
1111

1212
Install `@smooth-ui/core-sc` and `styled-components` from npm:
1313

@@ -22,20 +22,9 @@ You can use components in your React app:
2222
```js
2323
import { Button } from '@smooth-ui/core-sc'
2424

25-
const App = () => (
26-
<Button variant="primary">Hello world!</Button>
27-
)
25+
const App = () => <Button variant="primary">Hello world!</Button>
2826

2927
export default App
3028
```
3129

32-
## Global normalize (recommended)
33-
34-
Even if it is not required, is recommended to apply a global normalize before using Smooth UI.
35-
36-
```js
37-
import { globalStyle, createGlobalStyle } from '@smooth-ui/core-sc'
38-
const GlobalStyle = createGlobalStyle`${globalStyle()}`
39-
```
40-
41-
If you don't want to use a global normalize, at least add `* { box-sizing: border-box; }`.
30+
> Including `Normalize` is strongly recommended, see [guide](/docs-basics-normalize)].

0 commit comments

Comments
 (0)