Skip to content

Commit ab8ba40

Browse files
committed
feat: use emotion
1 parent 8eb1beb commit ab8ba40

40 files changed

+4900
-4976
lines changed

.babelrc

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@
1616
"publicPath": "./",
1717
"outputPath": "./dist/assets"
1818
}
19-
],
20-
[
21-
"babel-plugin-styled-components",
22-
{
23-
"namespace": "solvedac-",
24-
"displayName": false,
25-
"fileName": false
26-
}
2719
]
2820
]
2921
}

README.md

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,22 @@ Do not use this package in production! Almost every commit will be a breaking ch
1111
## Install
1212

1313
```bash
14-
yarn add @solved-ac/ui-react styled-components
14+
yarn add @solved-ac/ui-react @emotion/react @emotion/styled
1515
```
1616

1717
or, with npm:
1818

1919
```bash
20-
npm install --save @solved-ac/ui-react styled-components
20+
npm install --save @solved-ac/ui-react @emotion/react @emotion/styled
2121
```
2222

23-
### SSR
23+
## Usage
2424

25-
Setup module alias. Please refer to: https://styled-components.com/docs/faqs#linking-in-an-ssr-scenario
26-
27-
### Next.js
28-
29-
Modify `tsconfig.json` to setup module alias.
30-
31-
```json
32-
{
33-
"compilerOptions": {
34-
"paths": {
35-
"styled-components": ["./node_modules/styled-components"]
36-
}
37-
}
38-
}
25+
```jsx
26+
<ThemeProvider theme={solvedThemes.light}>
27+
<SolvedGlobalStyles />
28+
<Component />
29+
</ThemeProvider>
3930
```
4031

4132
## Contribute

example/.storybook/main.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
const path = require('path')
2+
3+
const toPath = (_path) => path.join(process.cwd(), _path)
4+
15
module.exports = {
26
core: {
37
builder: 'webpack5',
@@ -8,7 +12,18 @@ module.exports = {
812
'@storybook/addon-essentials',
913
'@storybook/addon-interactions',
1014
// '@storybook/preset-create-react-app',
11-
'storybook-addon-styled-component-theme/dist/preset',
1215
],
16+
webpackFinal: async (config) => ({
17+
...config,
18+
resolve: {
19+
...config.resolve,
20+
alias: {
21+
...config.resolve.alias,
22+
'@emotion/core': toPath('node_modules/@emotion/react'),
23+
'@emotion/styled': toPath('node_modules/@emotion/styled'),
24+
'emotion-theming': toPath('node_modules/@emotion/react'),
25+
},
26+
},
27+
}),
1328
framework: '@storybook/react',
1429
}

example/.storybook/preview.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React from 'react'
22
import { addDecorator } from '@storybook/react'
3-
import { withThemesProvider } from 'storybook-addon-styled-component-theme'
4-
import { ThemeProvider } from 'styled-components'
5-
import { solvedThemes, SolvedGlobalStyles } from '@solved-ac/ui-react'
3+
import { SolvedGlobalStyles, solvedThemes } from '@solved-ac/ui-react'
4+
import { ThemeProvider } from '@emotion/react'
65

76
export const parameters = {
87
actions: { argTypesRegex: '^on[A-Z].*' },
@@ -16,18 +15,9 @@ export const parameters = {
1615

1716
addDecorator((Story) => {
1817
return (
19-
<>
18+
<ThemeProvider theme={solvedThemes.light}>
2019
<SolvedGlobalStyles />
2120
<Story />
22-
</>
21+
</ThemeProvider>
2322
)
2423
})
25-
26-
addDecorator(
27-
withThemesProvider([
28-
solvedThemes.light,
29-
solvedThemes.dark,
30-
solvedThemes.black,
31-
]),
32-
ThemeProvider
33-
)

example/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
"@types/node": "link:../node_modules/@types/node",
2121
"@types/react": "link:../node_modules/@types/react",
2222
"@types/react-dom": "link:../node_modules/@types/react-dom",
23-
"@types/styled-components": "link:../node_modules/@types/styled-components",
2423
"react": "link:../node_modules/react",
2524
"react-dom": "link:../node_modules/react-dom",
25+
"@emotion/react": "link:../node_modules/@emotion/react",
26+
"@emotion/styled": "link:../node_modules/@emotion/styled",
2627
"react-scripts": "link:../node_modules/react-scripts",
27-
"styled-components": "link:../node_modules/styled-components",
2828
"typescript": "link:../node_modules/typescript"
2929
},
3030
"devDependencies": {

0 commit comments

Comments
 (0)