Skip to content

Commit 2e36fca

Browse files
feat: use twin.macro (#12)
1 parent 25ad49e commit 2e36fca

29 files changed

+3288
-2152
lines changed

.babelrc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"plugins": [
3+
"babel-plugin-macros",
4+
[
5+
"@emotion/babel-plugin-jsx-pragmatic",
6+
{
7+
"export": "jsx",
8+
"import": "__cssprop",
9+
"module": "@emotion/react"
10+
}
11+
],
12+
[
13+
"@babel/plugin-transform-react-jsx",
14+
{
15+
"pragma": "__cssprop",
16+
"pragmaFrag": "React.Fragment"
17+
}
18+
]
19+
]
20+
}

babel-plugin-macros.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
twin: {
3+
preset: 'emotion',
4+
},
5+
};

example/.npmignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
node_modules
22
.cache
3-
dist
3+
dist
4+
.babelrc
5+
babel-plugin-macros.config.js
6+
types/twin.d.ts

example/index.tsx

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'react-app-polyfill/ie11';
2+
23
import * as React from 'react';
34
import * as ReactDOM from 'react-dom';
45
import { Grid } from '../.';
@@ -43,10 +44,28 @@ const App = () => {
4344
}, [dataUrl, overrideDataUrl]);
4445

4546
return (
46-
<div className="relative h-full flex flex-col">
47-
<div className="p-4 mb-2 flex flex-col">
47+
<div
48+
style={{
49+
position: 'relative',
50+
height: '100%',
51+
display: 'flex',
52+
flexDirection: 'column',
53+
}}
54+
>
55+
<div
56+
style={{
57+
padding: 16,
58+
marginBottom: 8,
59+
display: 'flex',
60+
flexDirection: 'column',
61+
}}
62+
>
4863
<select
49-
className="p-4 mb-2"
64+
style={{
65+
padding: 16,
66+
marginBottom: 8,
67+
background: '#f4f4f4',
68+
}}
5069
value={dataUrl}
5170
onChange={e => setDataUrl(e.target.value)}
5271
>
@@ -60,14 +79,19 @@ const App = () => {
6079

6180
{!dataUrl && (
6281
<input
63-
className="block p-4 mt-2"
82+
style={{
83+
display: 'block',
84+
padding: 16,
85+
marginBottom: 8,
86+
background: '#f4f4f4',
87+
}}
6488
value={localOverrideDataUrl}
6589
onChange={e => setLocalOverrideDataUrl(e.target.value)}
6690
/>
6791
)}
6892
</div>
6993

70-
<div className="flex-1">{!isLoading && <Grid data={data} />}</div>
94+
<div style={{ flex: '1 1 0%' }}>{!isLoading && <Grid data={data} />}</div>
7195
</div>
7296
);
7397
};

example/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"scheduler/tracing": "../node_modules/scheduler/tracing-profiling"
2020
},
2121
"devDependencies": {
22+
"@babel/core": "^7.14.6",
2223
"@types/react": "^16.9.11",
2324
"@types/react-dom": "^16.8.4",
2425
"parcel": "^1.12.4",

0 commit comments

Comments
 (0)