Skip to content

Commit

Permalink
🔧 Bump alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldelcore committed Feb 22, 2021
1 parent 68fb54b commit 0528a9b
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 62 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
"@typescript-eslint/parser": "^1.4.2",
"babel-loader": "^8.0.6",
"babel-plugin-macros": "^3.0.0",
"babel-plugin-tester": "^10.0.0",
"eslint": "^5.15.1",
"eslint-config-prettier": "^4.1.0",
"eslint-plugin-prettier": "^3.0.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "@trousers/core",
"version": "4.0.0-alpha5",
"version": "4.0.0-alpha6",
"main": "dist/trousers-core.cjs.js",
"module": "dist/trousers-core.esm.js",
"types": "dist/index.d.ts",
"license": "MIT",
"dependencies": {
"@trousers/hash": "4.0.0-alpha5",
"@trousers/hash": "4.0.0-alpha6",
"csstype": "^2.5.7",
"tiny-css-prefixer": "^1.1.4"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/hash/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trousers/hash",
"version": "4.0.0-alpha5",
"version": "4.0.0-alpha6",
"main": "dist/trousers-hash.cjs.js",
"module": "dist/trousers-hash.esm.js",
"types": "dist/index.d.ts",
Expand Down
10 changes: 5 additions & 5 deletions packages/macro/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trousers/macro",
"version": "4.0.0-alpha5",
"version": "4.0.0-alpha6",
"main": "dist/trousers-macro.cjs.js",
"module": "dist/trousers-macro.esm.js",
"types": "dist/index.d.ts",
Expand All @@ -16,10 +16,10 @@
]
},
"dependencies": {
"@trousers/core": "4.0.0-alpha5",
"@trousers/hash": "4.0.0-alpha5",
"@trousers/react": "4.0.0-alpha5",
"@trousers/sheet": "4.0.0-alpha5",
"@trousers/core": "4.0.0-alpha6",
"@trousers/hash": "4.0.0-alpha6",
"@trousers/react": "4.0.0-alpha6",
"@trousers/sheet": "4.0.0-alpha6",
"babel-plugin-macros": "^3.0.0"
},
"devDependencies": {
Expand Down
45 changes: 27 additions & 18 deletions packages/macro/src/macro.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,27 +173,36 @@ function macro({ references, babel }) {
t.objectProperty(t.stringLiteral(id), value),
);

const TrousersNestedProps = [
...path.node.attributes.filter(
attr => attr.name.name !== 'styles',
),
t.jsxAttribute(
t.jsxIdentifier('elementType'),
t.stringLiteral(path.node.name.name),
),
];

const styleObjectProperties = [
...styleProperties,
...interpolationProperties,
];

if (styleObjectProperties.length) {
TrousersNestedProps.push(
t.jsxAttribute(
t.jsxIdentifier('style'),
t.jsxExpressionContainer(
t.objectExpression(styleObjectProperties),
),
),
);
}

path.replaceWith(
t.jsxOpeningElement(
t.jsxIdentifier(libraryMeta.runtimeComponent),
[
...path.node.attributes.filter(
attr => attr.name.name !== 'styles',
),
t.jsxAttribute(
t.jsxIdentifier('elementType'),
t.stringLiteral(path.node.name.name),
),
t.jsxAttribute(
t.jsxIdentifier('style'),
t.jsxExpressionContainer(
t.objectExpression([
...styleProperties,
...interpolationProperties,
]),
),
),
],
TrousersNestedProps,
path.node.selfClosing,
),
);
Expand Down
34 changes: 10 additions & 24 deletions packages/macro/src/macro.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// import pluginTester from 'babel-plugin-tester';
import { transformSync } from '@babel/core';
import plugin from 'babel-plugin-macros';

Expand All @@ -7,7 +6,6 @@ const transform = (code: TemplateStringsArray) => {
configFile: false,
babelrc: false,
filename: __filename,
// presets: ['@babel/preset-react'],
presets: [['@babel/preset-react', { runtime: 'automatic' }]],
plugins: [plugin],
})?.code;
Expand All @@ -34,7 +32,6 @@ describe('macro', () => {
const App = () => /*#__PURE__*/_jsx(TrousersNested, {
css: styles,
elementType: \\"button\\",
style: {},
children: \\"Submit\\"
});"
`);
Expand All @@ -59,7 +56,6 @@ describe('macro', () => {
const App = () => /*#__PURE__*/_jsx(TrousersNested, {
css: styles,
elementType: \\"button\\",
style: {},
children: \\"Submit\\"
});"
`);
Expand All @@ -81,14 +77,13 @@ describe('macro', () => {
const styles = css(\\"Button\\", {
\\".Button-2561700995\\": \\"color: blue;\\"
}).modifier(\\"primary\\", {
\\".Button--primary-2270159875\\": \\"color: brown;\\"
\\".Button-2561700995--primary-2270159875\\": \\"color: brown;\\"
});
const App = () => /*#__PURE__*/_jsx(TrousersNested, {
css: styles,
$primary: true,
elementType: \\"button\\",
style: {},
children: \\"Submit\\"
});"
`);
Expand All @@ -115,9 +110,9 @@ describe('macro', () => {
const styles = css(\\"Button\\", {
\\".Button-2561700995\\": \\"color: blue;\\"
}).modifier(\\"primary\\", {
\\".Button--primary-2270159875\\": \\"color: brown;\\"
\\".Button-2561700995--primary-2270159875\\": \\"color: brown;\\"
}).modifier(\\"secondary\\", {
\\".Button--secondary-3026956261\\": \\"color: purple;\\"
\\".Button-2561700995--secondary-3026956261\\": \\"color: purple;\\"
});
const App = ({
Expand All @@ -130,7 +125,6 @@ describe('macro', () => {
$primary: primary,
$secondary: secondary,
elementType: \\"button\\",
style: {},
children: \\"Submit\\"
});
};"
Expand All @@ -156,19 +150,18 @@ describe('macro', () => {
const styles = css(\\"Button\\", {
\\".Button-2561700995\\": \\"color: blue;\\"
}).modifier(\\"primary\\", {
\\".Button--primary-2270159875\\": \\"color: brown;\\"
\\".Button-2561700995--primary-2270159875\\": \\"color: brown;\\"
}).modifier(\\"secondary\\", {
\\".Button--secondary-3026956261\\": \\"color: purple;\\"
\\".Button-2561700995--secondary-3026956261\\": \\"color: purple;\\"
}).modifier(\\"tertiary\\", {
\\".Button--tertiary-41860765\\": \\"color: yellow;\\"
\\".Button-2561700995--tertiary-41860765\\": \\"color: yellow;\\"
}).modifier(\\"quaternary\\", {
\\".Button--quaternary-2402939536\\": \\"color: green;\\"
\\".Button-2561700995--quaternary-2402939536\\": \\"color: green;\\"
});
const App = () => /*#__PURE__*/_jsx(TrousersNested, {
css: styles,
elementType: \\"button\\",
style: {},
children: \\"Submit\\"
});"
`);
Expand All @@ -190,13 +183,12 @@ describe('macro', () => {
const styles = css(\\"Button\\", {
\\".Button-2140373281\\": \\"color: var(--brand-background);\\"
}).theme(\\"\\", {
\\".theme-Button-1537299292\\": \\"--brand-background: green;\\"
\\".theme-Button-2140373281-1537299292\\": \\"--brand-background: green;\\"
});
const App = () => /*#__PURE__*/_jsx(TrousersNested, {
css: styles,
elementType: \\"button\\",
style: {},
children: \\"Submit\\"
});"
`);
Expand Down Expand Up @@ -224,13 +216,12 @@ describe('macro', () => {
const styles = css(\\"Button\\", {
\\".Button-2140373281\\": \\"color: var(--brand-background);\\"
}).theme(\\"\\", {
\\".theme-Button-3270977004\\": \\"--neutral: #fff;--brand-forground: yellow;--brand-background: green;\\"
\\".theme-Button-2140373281-3270977004\\": \\"--neutral: #fff;--brand-forground: yellow;--brand-background: green;\\"
});
const App = () => /*#__PURE__*/_jsx(TrousersNested, {
css: styles,
elementType: \\"button\\",
style: {},
children: \\"Submit\\"
});"
`);
Expand All @@ -253,14 +244,13 @@ describe('macro', () => {
"import { jsx as _jsx } from \\"react/jsx-runtime\\";
import { css, TrousersNested } from \\"@trousers/macro/runtime\\";
import React from 'react';
const styles = css(\\"Button\\", {}).global(\\"global-Button-480010618\\", {
const styles = css(\\"Button\\", {}).global(\\"global-Button-3938-480010618\\", {
\\":root\\": \\"background-color: red;\\"
});
const App = () => /*#__PURE__*/_jsx(TrousersNested, {
css: styles,
elementType: \\"button\\",
style: {},
children: \\"Submit\\"
});"
`);
Expand All @@ -284,7 +274,6 @@ describe('macro', () => {
const App = () => /*#__PURE__*/_jsx(TrousersNested, {
css: styles,
elementType: \\"button\\",
style: {},
children: \\"Submit\\"
});"
`);
Expand Down Expand Up @@ -328,7 +317,6 @@ describe('macro', () => {
const App = () => /*#__PURE__*/_jsx(TrousersNested, {
css: styles,
elementType: \\"button\\",
style: {},
children: \\"Submit\\"
});"
`);
Expand All @@ -353,7 +341,6 @@ describe('macro', () => {
const App = () => /*#__PURE__*/_jsx(TrousersNested, {
css: styles,
elementType: \\"button\\",
style: {},
children: \\"Submit\\"
});"
`);
Expand All @@ -378,7 +365,6 @@ describe('macro', () => {
const App = () => /*#__PURE__*/_jsx(TrousersNested, {
css: styles,
elementType: \\"button\\",
style: {},
children: \\"Submit\\"
});"
`);
Expand Down
6 changes: 3 additions & 3 deletions packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@trousers/react",
"version": "4.0.0-alpha5",
"version": "4.0.0-alpha6",
"main": "dist/trousers-react.cjs.js",
"module": "dist/trousers-react.esm.js",
"types": "dist/index.d.ts",
"license": "MIT",
"dependencies": {
"@trousers/core": "4.0.0-alpha5",
"@trousers/sheet": "4.0.0-alpha5"
"@trousers/core": "4.0.0-alpha6",
"@trousers/sheet": "4.0.0-alpha6"
},
"devDependencies": {
"react": "^17.0.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/sheet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trousers/sheet",
"version": "4.0.0-alpha5",
"version": "4.0.0-alpha6",
"main": "dist/trousers-sheet.cjs.js",
"module": "dist/trousers-sheet.esm.js",
"types": "dist/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions packages/styled/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@trousers/styled",
"version": "4.0.0-alpha5",
"version": "4.0.0-alpha6",
"main": "dist/trousers-styled.cjs.js",
"module": "dist/trousers-styled.esm.js",
"types": "dist/index.d.ts",
"license": "MIT",
"dependencies": {
"@trousers/core": "4.0.0-alpha5",
"@trousers/react": "4.0.0-alpha5"
"@trousers/core": "4.0.0-alpha6",
"@trousers/react": "4.0.0-alpha6"
},
"devDependencies": {
"react": "^17.0.1"
Expand Down
8 changes: 4 additions & 4 deletions packages/trousers/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "trousers",
"version": "4.0.0-alpha5",
"version": "4.0.0-alpha6",
"main": "dist/trousers.cjs.js",
"module": "dist/trousers.esm.js",
"types": "dist/index.d.ts",
"license": "MIT",
"dependencies": {
"@trousers/core": "4.0.0-alpha5",
"@trousers/react": "4.0.0-alpha5",
"@trousers/styled": "4.0.0-alpha5"
"@trousers/core": "4.0.0-alpha6",
"@trousers/react": "4.0.0-alpha6",
"@trousers/styled": "4.0.0-alpha6"
},
"devDependencies": {
"react": "^17.0.1"
Expand Down

0 comments on commit 0528a9b

Please sign in to comment.