Skip to content

Commit

Permalink
💩 Temporary commit
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldelcore committed Feb 20, 2021
1 parent 771b794 commit a6e3bf2
Show file tree
Hide file tree
Showing 10 changed files with 696 additions and 897 deletions.
595 changes: 0 additions & 595 deletions packages/macro/src/__snapshots__/macro.spec.ts.snap

This file was deleted.

2 changes: 1 addition & 1 deletion packages/macro/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export type { CollectorReturn } from './stub';

//@ts-ignore written in JS
export * from './macro';
export { css, jsx } from './stub';
export { css } from './stub';
15 changes: 11 additions & 4 deletions packages/macro/src/macro.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,19 @@ function macro({ references, babel }) {
? stylesAttr.value.expression.properties
: [];

// ERROR: This code runs over opening elements multiple times....
// need to refactor this whole damn thing
jsxOpeningElement.replaceWith(
t.jsxOpeningElement(
jsxOpeningElement.node.name,
t.jsxIdentifier('TrousersNested'),
[
...jsxOpeningElement.node.attributes.filter(
attr => attr.name.name !== 'styles',
),
t.jsxAttribute(
t.jsxIdentifier('elementType'),
t.stringLiteral(jsxOpeningElement.node.name.name),
),
t.jsxAttribute(
t.jsxIdentifier('styles'),
t.jsxExpressionContainer(
Expand Down Expand Up @@ -192,14 +198,15 @@ function macro({ references, babel }) {
t.identifier(importName),
t.identifier(importName),
),
t.importSpecifier(t.identifier('jsx'), t.identifier('jsx')),
t.importSpecifier(
t.identifier('TrousersNested'),
t.identifier('TrousersNested'),
),
],
t.stringLiteral('@trousers/macro/runtime'),
),
);

program.addComment('leading', `* @jsx jsx `);

return {
keepImports: false,
};
Expand Down
Loading

0 comments on commit a6e3bf2

Please sign in to comment.