Skip to content

Commit 77f6926

Browse files
committed
refactor: rewrite compilation
1 parent 6468e48 commit 77f6926

25 files changed

+204
-209
lines changed

.flowconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[ignore]
2+
.*/node_modules/esformatter/.*
3+
.*/node_modules/fbjs/.*.flow
4+
.*/test/.*
5+
6+
[include]
7+
8+
[libs]
9+
decls
10+
11+
[options]
12+
esproposal.class_static_fields=enable
13+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue

decls/utils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
declare var expr;
2+
declare var stmt;

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,22 @@
4444
},
4545
"homepage": "https://github.com/andreypopp/react-css-components#readme",
4646
"dependencies": {
47+
"babel-plugin-ast-literal": "^0.4.0",
4748
"babel-types": "^6.7.2",
49+
"invariant": "^2.2.1",
4850
"loader-utils": "^0.2.14",
4951
"postcss": "^5.0.19",
50-
"babel-plugin-ast-literal": "^0.4.0"
52+
"postcss-selector-parser": "^1.3.3"
5153
},
5254
"devDependencies": {
5355
"babel-cli": "^6.7.5",
5456
"babel-core": "^6.7.6",
57+
"babel-generator": "^6.7.5",
5558
"babel-preset-prometheusresearch": "^0.1.0",
5659
"eslint": "^2.7.0",
5760
"eslint-config-prometheusresearch": "^0.2.0",
58-
"mocha": "^2.4.5",
59-
"babel-generator": "^6.7.5",
60-
"eslint-plugin-react": "^4.3.0"
61+
"eslint-plugin-react": "^4.3.0",
62+
"flow-bin": "^0.23.0",
63+
"mocha": "^2.4.5"
6164
}
6265
}

src/ComponentRef.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
* @flow
44
*/
55

6-
import * as types from 'babel-types';
7-
86
// TODO: More robust regexpes required!
97
const PARSE_REF_RE = /^([a-zA-Z0-9\._\-\/]+)(\?([a-zA-Z0-9_]+))?$/;
108
const PARSE_NAMED_REF_RE = /^([a-zA-Z0-9_]+)=([a-zA-Z0-9_\.\-\/]+)(\?([a-zA-Z0-9_]+))?$/;
@@ -31,16 +29,3 @@ export function parseNamed(ref: string): ?{id: string; ref: ComponentRef} {
3129
let [_everything, id, source, _nothing, name = 'default'] = match;
3230
return {id, ref: {source, name}};
3331
}
34-
35-
export function importDeclaration(identifier, ref: ComponentRef | string) {
36-
if (typeof ref === 'string') {
37-
ref = parse(ref);
38-
}
39-
let specifier;
40-
if (ref.name === 'default') {
41-
specifier = types.importDefaultSpecifier(identifier);
42-
} else {
43-
specifier = types.importSpecifier(identifier, types.identifier(ref.name));
44-
}
45-
return types.importDeclaration([specifier], types.stringLiteral(ref.source));
46-
}

src/Syntax.js

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.Label > .Hint,.Paragraph,.X:hover {
2+
color: red
3+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from "react";
2+
import styles from "css";
3+
export function Label(props) {
4+
return React.createElement("div", { ...props, className: styles.Label
5+
});
6+
}
7+
export function Hint(props) {
8+
return React.createElement("div", { ...props, className: styles.Hint
9+
});
10+
}
11+
export function Paragraph(props) {
12+
return React.createElement("div", { ...props, className: styles.Paragraph
13+
});
14+
}
15+
export function X(props) {
16+
return React.createElement("div", { ...props, className: styles.X
17+
});
18+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Label > Hint, Paragraph, X:hover {
2+
color: red;
3+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
:local(.Label) {
1+
.Label {
22
color: red
33
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
:local(.Label) {
1+
.Label {
22
color: red
33
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
:local(.Label) {
1+
.Label {
22
color: red
33
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.Label:hover {
2+
color: red
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Label:hover {
2+
color: red;
3+
}

src/__tests__/fixtures/pseudo-nested.css

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/__tests__/fixtures/pseudo-nested.react.css

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/__tests__/fixtures/pseudo.css

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/__tests__/fixtures/pseudo.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/__tests__/fixtures/pseudo.react.css

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
:local(.Label) {
1+
.Label {
22
color: red
33
}
4-
:local(.Label:hover) {
4+
.Label:hover {
55
color: red
66
}

src/__tests__/fixtures/simple.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
:local(.Label) {
1+
.Label {
22
color: red
33
}

src/__tests__/fixtures/within-media.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
:local(.Label) {
1+
.Label {
22

33
color: red
44
}
55

66
@media (min-width: 1000px) {
7-
:local(.Label) {
7+
.Label {
88

99
color: white
1010
}

src/__tests__/index-test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import {render} from '../';
1010

1111
const REACT_CSS_RE = /\.react\.css$/;
1212

13+
declare function describe(description: string, body: any): void;
14+
declare function it(description: string, body: any): void;
15+
1316
describe('react-css-components', function() {
1417

1518
function readFixture(filename) {

0 commit comments

Comments
 (0)