diff --git a/.all-contributorsrc b/.all-contributorsrc index 1b6609c..5157058 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -127,6 +127,15 @@ "contributions": [ "code" ] + }, + { + "login": "satya164", + "name": "Satyajit Sahoo", + "avatar_url": "https://avatars2.githubusercontent.com/u/1174278?v=4", + "profile": "https://twitter.com/@satya164", + "contributions": [ + "code" + ] } ] } diff --git a/package.json b/package.json index c881b3c..3c613c2 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "dependencies": { "@tsuyoshiwada/htmltojsx": "^0.0.5", "babel-plugin-json-to-proptypes": "^0.1.0", + "babel-plugin-object-styles-to-template": "^0.1.2", "babel-standalone": "^6.26.0", "classnames": "^2.2.5", "codemirror": "^5.30.0", diff --git a/pages/object-styles-to-template-literal.js b/pages/object-styles-to-template-literal.js new file mode 100644 index 0000000..9c2c7e3 --- /dev/null +++ b/pages/object-styles-to-template-literal.js @@ -0,0 +1,47 @@ +import React, { PureComponent } from "react"; +import Layout from "../components/Layout"; +import merge from "lodash/merge"; +import loadWorker from "../utils/loadWorker"; + +import ConversionPanel from "../components/ConversionPanel"; + +const defaultText = `const container = css({ + flex: 1, + padding: 10, + backgroundColor: 'orange', + color: colors.white, + + '&:hover': { + backgroundColor: 'tomato', + } +}); +`; + +export default class Main extends PureComponent { + state = { + isImmutable: false + }; + + getTransformedValue = code => { + this.promiseWorker = loadWorker( + "object-styles-to-template-literal.js", + this + ).promiseWorker; + return this.promiseWorker.postMessage(code); + }; + + render() { + return ( + + + + ); + } +} diff --git a/readme.md b/readme.md index f303d37..f939574 100644 --- a/readme.md +++ b/readme.md @@ -45,9 +45,10 @@ MIT @ Ritesh Kumar Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)): -| [
Ritesh Kumar](http://riteshkr.com)
[📖](https://github.com/ritz078/transform-www/commits?author=ritz078 "Documentation") [💻](https://github.com/ritz078/transform-www/commits?author=ritz078 "Code") [🤔](#ideas-ritz078 "Ideas, Planning, & Feedback") [👀](#review-ritz078 "Reviewed Pull Requests") | [
Florian Gilcher](http://asquera.de)
[💻](https://github.com/ritz078/transform-www/commits?author=skade "Code") | [
Pascal Hertleif](http://pascalhertleif.de/)
[💻](https://github.com/ritz078/transform-www/commits?author=killercup "Code") | [
Lado Lomidze](http://landish.github.io)
[💻](https://github.com/ritz078/transform-www/commits?author=Landish "Code") | [
Mattia Manzati](https://github.com/mattiamanzati)
[💻](https://github.com/ritz078/transform-www/commits?author=mattiamanzati "Code") | [
Mohammad Rajabifard](https://tarino.ir)
[🤔](#ideas-morajabi "Ideas, Planning, & Feedback") [💻](https://github.com/ritz078/transform-www/commits?author=morajabi "Code") | [
Raathigeshan Kugarajan](http://raathigesh.com/)
[💻](https://github.com/ritz078/transform-www/commits?author=Raathigesh "Code") | + +| [
Ritesh Kumar](http://riteshkr.com)
[📖](https://github.com/ritz078/transform-www/commits?author=ritz078 "Documentation") [💻](https://github.com/ritz078/transform-www/commits?author=ritz078 "Code") [🤔](#ideas-ritz078 "Ideas, Planning, & Feedback") [👀](#review-ritz078 "Reviewed Pull Requests") | [
Florian Gilcher](http://asquera.de)
[💻](https://github.com/ritz078/transform-www/commits?author=skade "Code") | [
Pascal Hertleif](http://pascalhertleif.de/)
[💻](https://github.com/ritz078/transform-www/commits?author=killercup "Code") | [
Lado Lomidze](http://landish.github.io)
[💻](https://github.com/ritz078/transform-www/commits?author=Landish "Code") | [
Mattia Manzati](https://github.com/mattiamanzati)
[💻](https://github.com/ritz078/transform-www/commits?author=mattiamanzati "Code") | [
Mohammad Rajabifard](https://tarino.ir)
[🤔](#ideas-morajabi "Ideas, Planning, & Feedback") [💻](https://github.com/ritz078/transform-www/commits?author=morajabi "Code") | [
Raathigeshan Kugarajan](http://raathigesh.com/)
[💻](https://github.com/ritz078/transform-www/commits?author=Raathigesh "Code") | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | -| [
Gyandeep Singh](https://gyandeeps.com)
[💻](https://github.com/ritz078/transform-www/commits?author=gyandeeps "Code") | [
Matt Holt](https://matt.life)
[💻](https://github.com/ritz078/transform-www/commits?author=mholt "Code") | [
sreenivas alapati](https://medium.com/@sreenivas)
[💻](https://github.com/ritz078/transform-www/commits?author=cg-cnu "Code") | [
Boris Cherny](https://performancejs.com)
[💻](https://github.com/ritz078/transform-www/commits?author=bcherny "Code") | [
Mark Lussier](http://www.twitter.com/intabulas)
[💻](https://github.com/ritz078/transform-www/commits?author=intabulas "Code") | [
Brice BERNARD](https://github.com/brikou)
[💻](https://github.com/ritz078/transform-www/commits?author=brikou "Code") | +| [
Gyandeep Singh](https://gyandeeps.com)
[💻](https://github.com/ritz078/transform-www/commits?author=gyandeeps "Code") | [
Matt Holt](https://matt.life)
[💻](https://github.com/ritz078/transform-www/commits?author=mholt "Code") | [
sreenivas alapati](https://medium.com/@sreenivas)
[💻](https://github.com/ritz078/transform-www/commits?author=cg-cnu "Code") | [
Boris Cherny](https://performancejs.com)
[💻](https://github.com/ritz078/transform-www/commits?author=bcherny "Code") | [
Mark Lussier](http://www.twitter.com/intabulas)
[💻](https://github.com/ritz078/transform-www/commits?author=intabulas "Code") | [
Brice BERNARD](https://github.com/brikou)
[💻](https://github.com/ritz078/transform-www/commits?author=brikou "Code") | [
Satyajit Sahoo](https://twitter.com/@satya164)
[💻](https://github.com/ritz078/transform-www/commits?author=satya164 "Code") | This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! diff --git a/utils/routes.js b/utils/routes.js index 554e323..c2cad11 100644 --- a/utils/routes.js +++ b/utils/routes.js @@ -72,6 +72,14 @@ export const categorizedRoutes = [ packageName: "css-in-js-generator", packageUrl: "https://github.com/brikou/CSS-in-JS-generator", beta: true + }, + { + label: "Object Styles to template literal", + path: "/object-styles-to-template-literal", + desc: "An online REPL to convert object styles to template literal.", + packageUrl: + "https://github.com/satya164/babel-plugin-object-styles-to-template", + packageName: "babel-plugin-object-styles-to-template" } ] }, diff --git a/workers/object-styles-to-template-literal.js b/workers/object-styles-to-template-literal.js new file mode 100644 index 0000000..4ced6c8 --- /dev/null +++ b/workers/object-styles-to-template-literal.js @@ -0,0 +1,15 @@ +import { transform } from "babel-standalone"; +import convert from "babel-plugin-object-styles-to-template"; +import immutablePropsPlugin from "../utils/babel-plugin-js-to-immutable-prop-types"; +import registerPromiseWorker from "promise-worker/register"; + +registerPromiseWorker( + code => + new Promise(resolve => { + const newCode = transform(code, { + plugins: [convert] + }).code; + + resolve(`${newCode}`); + }) +); diff --git a/yarn.lock b/yarn.lock index 65da53c..c0a9098 100644 --- a/yarn.lock +++ b/yarn.lock @@ -127,8 +127,8 @@ ajv@^5.0.0: json-schema-traverse "^0.3.0" ajv@^5.1.0: - version "5.4.0" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.4.0.tgz#32d1cf08dbc80c432f426f12e10b2511f6b46474" + version "5.5.0" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.0.tgz#eb2840746e9dc48bd5e063a36e3fd400c5eab5a9" dependencies: co "^4.6.0" fast-deep-equal "^1.0.0" @@ -164,8 +164,8 @@ all-contributors-cli@^4.4.0: yargs "^4.7.0" all-contributors-cli@^4.5.0: - version "4.9.1" - resolved "https://registry.yarnpkg.com/all-contributors-cli/-/all-contributors-cli-4.9.1.tgz#8120b652bcbaca37e125386c775895e0dcaa5cd3" + version "4.10.0" + resolved "https://registry.yarnpkg.com/all-contributors-cli/-/all-contributors-cli-4.10.0.tgz#262a747a50a353bb95eba1df0b1a383e5acb6b60" dependencies: async "^2.0.0-rc.1" chalk "^2.3.0" @@ -714,6 +714,10 @@ babel-plugin-module-resolver@2.7.1: glob "^7.1.1" resolve "^1.2.0" +babel-plugin-object-styles-to-template@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/babel-plugin-object-styles-to-template/-/babel-plugin-object-styles-to-template-0.1.2.tgz#59aefe65da0eb8d5bd94143190bce9e27e785c3a" + babel-plugin-react-require@3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/babel-plugin-react-require/-/babel-plugin-react-require-3.0.0.tgz#2e4e7b4496b93a654a1c80042276de4e4eeb20e3" @@ -1735,11 +1739,11 @@ codeclimate-test-reporter@^0.5.0: request "~2.79.0" codemirror-graphql@^0.6.11: - version "0.6.11" - resolved "https://registry.yarnpkg.com/codemirror-graphql/-/codemirror-graphql-0.6.11.tgz#795efa3933523815a5245eefe8d6831d3c4ad026" + version "0.6.12" + resolved "https://registry.yarnpkg.com/codemirror-graphql/-/codemirror-graphql-0.6.12.tgz#91a273fe5188857524a30221d06e645b4ca41f00" dependencies: - graphql-language-service-interface "0.0.19" - graphql-language-service-parser "0.0.15" + graphql-language-service-interface "^1.0.16" + graphql-language-service-parser "^0.1.14" codemirror@^5.30.0: version "5.32.0" @@ -2027,6 +2031,13 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4: safe-buffer "^5.0.1" sha.js "^2.4.8" +cross-fetch@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-0.0.8.tgz#01ed94dc407df2c00f1807fde700a7cfa48a205c" + dependencies: + node-fetch "1.7.3" + whatwg-fetch "2.0.3" + cross-spawn@5.1.0, cross-spawn@^5.0.1: version "5.1.0" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" @@ -3196,47 +3207,60 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.4, graceful-fs@^4.1.6: version "1.0.1" resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" -graphql-language-service-config@0.0.17: - version "0.0.17" - resolved "https://registry.yarnpkg.com/graphql-language-service-config/-/graphql-language-service-config-0.0.17.tgz#36b5a9906c0bf0d356d31b7583058f9b85d1793e" +graphql-config@1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/graphql-config/-/graphql-config-1.0.8.tgz#6dd1cd76ff6fbb01662704f8bddc403f6b0c24d9" dependencies: - graphql-language-service-types "0.0.21" + graphql "^0.11.7" + graphql-request "^1.4.0" + js-yaml "^3.10.0" + minimatch "^3.0.4" + rimraf "^2.6.2" -graphql-language-service-interface@0.0.19: - version "0.0.19" - resolved "https://registry.yarnpkg.com/graphql-language-service-interface/-/graphql-language-service-interface-0.0.19.tgz#c58fa7bd95d2f30e33e04937a1a2c00a9740926e" +graphql-language-service-interface@^1.0.16: + version "1.0.16" + resolved "https://registry.yarnpkg.com/graphql-language-service-interface/-/graphql-language-service-interface-1.0.16.tgz#0e6dd855bf0bdee84e7456b2128a2e5f56e4f47b" dependencies: - graphql "^0.10.1" - graphql-language-service-config "0.0.17" - graphql-language-service-parser "0.0.15" - graphql-language-service-types "0.0.21" - graphql-language-service-utils "0.0.17" + graphql-config "1.0.8" + graphql-language-service-parser "^0.1.14" + graphql-language-service-types "^0.1.14" + graphql-language-service-utils "^1.0.16" -graphql-language-service-parser@0.0.15: - version "0.0.15" - resolved "https://registry.yarnpkg.com/graphql-language-service-parser/-/graphql-language-service-parser-0.0.15.tgz#fd64afd8873624fa3c4a5831a08de9ccd6cc5182" +graphql-language-service-parser@^0.1.14: + version "0.1.14" + resolved "https://registry.yarnpkg.com/graphql-language-service-parser/-/graphql-language-service-parser-0.1.14.tgz#dd25abda5dcff4f2268c9a19e026004271491661" dependencies: - graphql-language-service-types "0.0.21" + graphql-language-service-types "^0.1.14" -graphql-language-service-types@0.0.21: - version "0.0.21" - resolved "https://registry.yarnpkg.com/graphql-language-service-types/-/graphql-language-service-types-0.0.21.tgz#b9453366fc8985765034bf34056fe93603a24b82" +graphql-language-service-types@^0.1.14: + version "0.1.14" + resolved "https://registry.yarnpkg.com/graphql-language-service-types/-/graphql-language-service-types-0.1.14.tgz#e6112785fc23ea8222f59a7f00e61b359f263c88" + +graphql-language-service-utils@^1.0.16: + version "1.0.16" + resolved "https://registry.yarnpkg.com/graphql-language-service-utils/-/graphql-language-service-utils-1.0.16.tgz#eb4e4495aeef0c4b6ffd8c681858558862c65e9e" dependencies: - graphql "^0.10.1" + graphql-config "1.0.8" + graphql-language-service-types "^0.1.14" -graphql-language-service-utils@0.0.17: - version "0.0.17" - resolved "https://registry.yarnpkg.com/graphql-language-service-utils/-/graphql-language-service-utils-0.0.17.tgz#a8b91eca80c6aa5a0d461a0bbb63317986f9b989" +graphql-request@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/graphql-request/-/graphql-request-1.4.0.tgz#f5b067c83070296d93fb45760e83dfad0d9f537a" dependencies: - graphql "^0.10.1" - graphql-language-service-types "0.0.21" + cross-fetch "0.0.8" -graphql@^0.10.1, graphql@^0.10.5: +graphql@^0.10.5: version "0.10.5" resolved "https://registry.yarnpkg.com/graphql/-/graphql-0.10.5.tgz#c9be17ca2bdfdbd134077ffd9bbaa48b8becd298" dependencies: iterall "^1.1.0" +graphql@^0.11.7: + version "0.11.7" + resolved "https://registry.yarnpkg.com/graphql/-/graphql-0.11.7.tgz#e5abaa9cb7b7cccb84e9f0836bf4370d268750c6" + dependencies: + iterall "1.1.3" + gzip-size@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/gzip-size/-/gzip-size-3.0.0.tgz#546188e9bdc337f673772f81660464b389dce520" @@ -3835,9 +3859,9 @@ isstream@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" -iterall@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/iterall/-/iterall-1.1.1.tgz#f7f0af11e9a04ec6426260f5019d9fcca4d50214" +iterall@1.1.3, iterall@^1.1.0: + version "1.1.3" + resolved "https://registry.yarnpkg.com/iterall/-/iterall-1.1.3.tgz#1cbbff96204056dde6656e2ed2e2226d0e6d72c9" jest-get-type@^21.2.0: version "21.2.0" @@ -3869,7 +3893,7 @@ js-tokens@^3.0.0, js-tokens@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" -js-yaml@^3.4.3, js-yaml@^3.9.1: +js-yaml@^3.10.0, js-yaml@^3.4.3, js-yaml@^3.9.1: version "3.10.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.10.0.tgz#2e78441646bd4682e963f22b6e92823c309c62dc" dependencies: @@ -4649,7 +4673,7 @@ no-case@^2.2.0: dependencies: lower-case "^1.1.1" -node-fetch@^1.0.1: +node-fetch@1.7.3, node-fetch@^1.0.1: version "1.7.3" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef" dependencies: @@ -6093,7 +6117,7 @@ rimraf@2, rimraf@^2.5.1, rimraf@^2.6.1: dependencies: glob "^7.0.5" -rimraf@^2.2.8: +rimraf@^2.2.8, rimraf@^2.6.2: version "2.6.2" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" dependencies: @@ -7165,7 +7189,7 @@ webpack@3.6.0: webpack-sources "^1.0.1" yargs "^8.0.2" -whatwg-fetch@>=0.10.0: +whatwg-fetch@2.0.3, whatwg-fetch@>=0.10.0: version "2.0.3" resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84"