diff --git a/components/ConversionPanel.js b/components/ConversionPanel.js index 5a8550c..09116b4 100644 --- a/components/ConversionPanel.js +++ b/components/ConversionPanel.js @@ -17,19 +17,18 @@ if (isBrowser) { require('brace/theme/tomorrow') } - - export default class ConversionPanel extends PureComponent { static propTypes = { - plugin: PropTypes.func.isRequired, name: PropTypes.string.isRequired, leftMode: PropTypes.string, - rightMode: PropTypes.string + rightMode: PropTypes.string, + pathname: PropTypes.string } static defaultProps = { leftMode: 'javascript', - rightMode: 'javascript' + rightMode: 'javascript', + pathname: '/' } constructor (props) { @@ -88,11 +87,11 @@ export default class ConversionPanel extends PureComponent { render () { return ( - +
- Transform | Convert an object to propTypes - + Transform | Online code transformation +
+
- -
Created by @ritz078 + +
Created by @ritz078
diff --git a/next.config.js b/next.config.js index 706ab40..ba7e661 100644 --- a/next.config.js +++ b/next.config.js @@ -7,6 +7,13 @@ module.exports = { config.node = { fs: 'empty' } + + if (!dev) { + config.plugins.push( + new BabiliPlugin() + ) + } + return config; } }; \ No newline at end of file diff --git a/package.json b/package.json index 1ea4b37..6157376 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "transform", - "version": "1.0.0", + "version": "2.0.0", "description": "", "main": "index.js", "scripts": { @@ -18,13 +18,16 @@ "copy-text-to-clipboard": "^1.0.2", "is-in-browser": "^1.1.3", "js-beautify": "^1.6.14", + "json2dts": "^0.0.2", "lodash": "^4.17.4", "next": "^2.4.9", + "nprogress": "^0.2.0", "prop-types": "^15.5.10", "react": "^15.6.1", "react-ace": "^5.1.2", "react-alert": "^2.2.0", "react-dom": "^15.6.1", + "react-github-corner": "^0.3.0", "react-toastify": "^1.7.0", "store2": "^2.5.1" } diff --git a/pages/index.js b/pages/index.js index 03801a8..d6866af 100644 --- a/pages/index.js +++ b/pages/index.js @@ -1,6 +1,6 @@ import React, {PureComponent} from 'react' import { transform } from 'babel-standalone' -import plugin from '../utils/plugin' +import plugin from '../utils/babel-plugin-js-to-prop-types' import ConversionPanel from '../components/ConversionPanel' const defaultText = `// Enter the object you want to convert in the diff --git a/pages/json-to-ts-interface.js b/pages/json-to-ts-interface.js new file mode 100644 index 0000000..3f1d8af --- /dev/null +++ b/pages/json-to-ts-interface.js @@ -0,0 +1,48 @@ +import React, { PureComponent } from 'react' +import { Json2dts, toValidJSON } from 'json2dts' +import isBrowser from 'is-in-browser' +import ConversionPanel from '../components/ConversionPanel' + +let brace +let AceEditor +if (isBrowser) { + brace = require('brace').default + AceEditor = require('react-ace').default + require('brace/mode/json') +} + +const defaultText = ` +{ + "foo": "bar", + "ids": [1, 2, 3], + "hello": { + "x": "lkjlj", + "y": "kjhkjhkjh" + } +} +` + + +export default class Json2Ts extends PureComponent { + getTransformedValue = (newValue) => { + const converter = new Json2dts() + let text2Obj = JSON.parse(toValidJSON(newValue)) + if (typeof text2Obj !== 'object' || Array.isArray(text2Obj)) { + throw new Error('Pass a valid JSON Object. Arrays are not acceptable even though they are valid JSON.') + } + converter.parse(text2Obj, 'RootJson') + return converter.getCode() + } + + render () { + return ( + + ) + } +} diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..20f37b1 --- /dev/null +++ b/readme.md @@ -0,0 +1,16 @@ +# transform-www + +> Website for https://transform.now.sh + +This project is based on [next.js](https://github.com/zeit/next.js/) + +## Development + +- Fork the repo +- Create a new branch. +- `yarn install` +- `yarn dev` then fix issues or add features. +- Make a pull request. + +## License +MIT @ Ritesh Kumar \ No newline at end of file diff --git a/static/nprogress.css b/static/nprogress.css new file mode 100644 index 0000000..59720c8 --- /dev/null +++ b/static/nprogress.css @@ -0,0 +1,74 @@ +/* Make clicks pass-through */ +#nprogress { + pointer-events: none; +} + +#nprogress .bar { + background: #29d; + + position: fixed; + z-index: 1031; + top: 0; + left: 0; + + width: 100%; + height: 2px; +} + +/* Fancy blur effect */ +#nprogress .peg { + display: block; + position: absolute; + right: 0px; + width: 100px; + height: 100%; + box-shadow: 0 0 10px #29d, 0 0 5px #29d; + opacity: 1.0; + + -webkit-transform: rotate(3deg) translate(0px, -4px); + -ms-transform: rotate(3deg) translate(0px, -4px); + transform: rotate(3deg) translate(0px, -4px); +} + +/* Remove these to get rid of the spinner */ +#nprogress .spinner { + display: block; + position: fixed; + z-index: 1031; + top: 15px; + right: 15px; +} + +#nprogress .spinner-icon { + width: 18px; + height: 18px; + box-sizing: border-box; + + border: solid 2px transparent; + border-top-color: #29d; + border-left-color: #29d; + border-radius: 50%; + + -webkit-animation: nprogress-spinner 400ms linear infinite; + animation: nprogress-spinner 400ms linear infinite; +} + +.nprogress-custom-parent { + overflow: hidden; + position: relative; +} + +.nprogress-custom-parent #nprogress .spinner, +.nprogress-custom-parent #nprogress .bar { + position: absolute; +} + +@-webkit-keyframes nprogress-spinner { + 0% { -webkit-transform: rotate(0deg); } + 100% { -webkit-transform: rotate(360deg); } +} +@keyframes nprogress-spinner { + 0% { transform: rotate(0deg); } + 100% { transform: rotate(360deg); } +} + diff --git a/utils/plugin.js b/utils/babel-plugin-js-to-prop-types.js similarity index 100% rename from utils/plugin.js rename to utils/babel-plugin-js-to-prop-types.js diff --git a/yarn.lock b/yarn.lock index f8f42db..05877ee 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1165,6 +1165,10 @@ camelcase@^1.0.2: version "1.2.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39" +camelcase@^2.0.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" + camelcase@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-3.0.0.tgz#32fc4b9fcdaf845fcdf7e73bb97cac2261f0ab0a" @@ -1241,7 +1245,7 @@ cliui@^2.1.0: right-align "^0.1.1" wordwrap "0.0.2" -cliui@^3.2.0: +cliui@^3.0.3, cliui@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/cliui/-/cliui-3.2.0.tgz#120601537a916d29940f934da3b48d585a39213d" dependencies: @@ -2316,6 +2320,12 @@ json-stringify-safe@~5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" +json2dts@^0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/json2dts/-/json2dts-0.0.2.tgz#2799bde183420b804ad7ffcd2c487e6bbcfa6ec5" + dependencies: + yargs "^3.15.0" + json5@^0.5.0, json5@^0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" @@ -2734,6 +2744,10 @@ npmlog@^4.0.2: gauge "~2.7.3" set-blocking "~2.0.0" +nprogress@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/nprogress/-/nprogress-0.2.0.tgz#cb8f34c53213d895723fcbab907e9422adbcafb1" + number-is-nan@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" @@ -3096,6 +3110,10 @@ react-dom@^15.6.1: object-assign "^4.1.0" prop-types "^15.5.10" +react-github-corner@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/react-github-corner/-/react-github-corner-0.3.0.tgz#b34c613e6f9cceb49fbe51378b78a9061af4da98" + react-hot-loader@3.0.0-beta.7: version "3.0.0-beta.7" resolved "https://registry.yarnpkg.com/react-hot-loader/-/react-hot-loader-3.0.0-beta.7.tgz#d5847b8165d731c4d5b30d86d5d4716227a0fa83" @@ -3898,6 +3916,10 @@ window-size@0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d" +window-size@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.4.tgz#f8e1aa1ee5a53ec5bf151ffa09742a6ad7697876" + window@3.1.5: version "3.1.5" resolved "https://registry.yarnpkg.com/window/-/window-3.1.5.tgz#dacd813d54efa5da9647dbc281855f12b89664bb" @@ -3945,7 +3967,7 @@ xtend@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" -y18n@^3.2.1: +y18n@^3.2.0, y18n@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41" @@ -3959,6 +3981,18 @@ yargs-parser@^4.2.0: dependencies: camelcase "^3.0.0" +yargs@^3.15.0: + version "3.32.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.32.0.tgz#03088e9ebf9e756b69751611d2a5ef591482c995" + dependencies: + camelcase "^2.0.1" + cliui "^3.0.3" + decamelize "^1.1.1" + os-locale "^1.4.0" + string-width "^1.0.1" + window-size "^0.1.4" + y18n "^3.2.0" + yargs@^6.0.0: version "6.6.0" resolved "https://registry.yarnpkg.com/yargs/-/yargs-6.6.0.tgz#782ec21ef403345f830a808ca3d513af56065208"