mirror of
https://github.com/ritz078/transform.git
synced 2026-11-22 17:11:32 +03:00
dummy json
This commit is contained in:
1 parent
a18b8bb038
commit
3314881fd8
7 files changed
+52
-43
No files matched your search
@@ -45,7 +45,6 @@ export default class ConversionPanel extends PureComponent {
|
||||
}
|
||||
|
||||
componentDidMount () {
|
||||
const {name} = this.props
|
||||
const code = this.props.url.query.code || this.props.defaultText
|
||||
this.setState({
|
||||
value: code,
|
||||
@@ -53,11 +52,6 @@ export default class ConversionPanel extends PureComponent {
|
||||
})
|
||||
}
|
||||
|
||||
shouldComponentUpdate(nextProps, nextState) {
|
||||
console.log(nextProps, this.props, nextState)
|
||||
return true
|
||||
}
|
||||
|
||||
onChange = (newValue) => {
|
||||
try {
|
||||
const code = this.props.getTransformedValue(newValue)
|
||||
|
||||
@@ -153,7 +153,7 @@ export default function ({children, pathname}) {
|
||||
<Logo/>
|
||||
</div>
|
||||
<ul>
|
||||
<li className={getClass("/")}><Link prefetch href="/"><a>JS Object to React PropTypes</a></Link></li>
|
||||
<li className={getClass("/")}><Link prefetch href="/"><a>JSON to React PropTypes</a></Link></li>
|
||||
<li className={getClass("/json-to-flow-types")}><Link prefetch href="/json-to-flow-types"><a>JSON to Flow Types</a></Link></li>
|
||||
<li className={getClass("/json-to-ts-interface")}><Link prefetch href="/json-to-ts-interface"><a>JSON to Typescript Interface</a></Link></li>
|
||||
<li className={getClass("/css-to-js")}><Link prefetch href="/css-to-js"><a>CSS to JS Objects</a></Link></li>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React, { PureComponent } from 'react'
|
||||
import dynamic from 'next/dynamic'
|
||||
import plugin from '../utils/css-to-js'
|
||||
import Layout from '../components/Layout'
|
||||
import ConversionPanel from '../components/ConversionPanel'
|
||||
|
||||
+3
-13
@@ -2,24 +2,13 @@ import React, { PureComponent } from 'react'
|
||||
import plugin from '../utils/babel-plugin-js-to-prop-types'
|
||||
import Layout from '../components/Layout'
|
||||
import { transform } from 'babel-standalone'
|
||||
import defaultText from '../utils/dummy-json'
|
||||
|
||||
import ConversionPanel from '../components/ConversionPanel'
|
||||
|
||||
const defaultText = `// Enter the object you want to convert in the
|
||||
// following form
|
||||
//
|
||||
// const x = your_object
|
||||
//
|
||||
// You need to assign your object to a variable (for now.)
|
||||
|
||||
const x = {
|
||||
foo: 'bar',
|
||||
ids: [1, 2, 3]
|
||||
}
|
||||
`
|
||||
|
||||
export default class Main extends PureComponent {
|
||||
getTransformedValue = (newValue) => {
|
||||
newValue = 'const propTypes = ' + newValue
|
||||
const {code} = transform(newValue, {
|
||||
presets: ['es2015'],
|
||||
plugins: [plugin]
|
||||
@@ -32,6 +21,7 @@ export default class Main extends PureComponent {
|
||||
<Layout pathname={this.props.url.pathname}>
|
||||
<ConversionPanel
|
||||
url={this.props.url}
|
||||
leftMode="json"
|
||||
getTransformedValue={this.getTransformedValue}
|
||||
name={'prop_types'}
|
||||
defaultText={defaultText}
|
||||
|
||||
@@ -3,17 +3,7 @@ import dynamic from 'next/dynamic'
|
||||
import { Json2dts, toValidJSON } from '../utils/json-to-ts-flow'
|
||||
import Layout from '../components/Layout'
|
||||
import ConversionPanel from '../components/ConversionPanel'
|
||||
|
||||
const defaultText = `
|
||||
{
|
||||
"foo": "bar",
|
||||
"ids": [1, 2, 3],
|
||||
"hello": {
|
||||
"x": "lkjlj",
|
||||
"y": "kjhkjhkjh"
|
||||
}
|
||||
}
|
||||
`
|
||||
import defaultText from '../utils/dummy-json'
|
||||
|
||||
export default class Json2Ts extends PureComponent {
|
||||
getTransformedValue = (newValue) => {
|
||||
|
||||
@@ -3,17 +3,7 @@ import dynamic from 'next/dynamic'
|
||||
import { Json2dts, toValidJSON } from '../utils/json-to-ts-flow'
|
||||
import Layout from '../components/Layout'
|
||||
import ConversionPanel from '../components/ConversionPanel'
|
||||
|
||||
const defaultText = `
|
||||
{
|
||||
"foo": "bar",
|
||||
"ids": [1, 2, 3],
|
||||
"hello": {
|
||||
"x": "lkjlj",
|
||||
"y": "kjhkjhkjh"
|
||||
}
|
||||
}
|
||||
`
|
||||
import defaultText from '../utils/dummy-json'
|
||||
|
||||
export default class Json2Ts extends PureComponent {
|
||||
getTransformedValue = (newValue) => {
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
const x = `
|
||||
{
|
||||
"hello": [
|
||||
{
|
||||
"_id": "5988946e45e52d60b33a25c7",
|
||||
"latitude": 50.087977,
|
||||
"longitude": 72.167197,
|
||||
"tags": [
|
||||
"nulla",
|
||||
"ullamco"
|
||||
],
|
||||
"friends": [
|
||||
{
|
||||
"id": 0,
|
||||
"name": "Robinson Woods"
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Lottie Hogan"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"_id": "5988946ef6090217857d7b0f",
|
||||
"latitude": 47.460772,
|
||||
"longitude": 85.95137,
|
||||
"tags": [
|
||||
"aliqua",
|
||||
"nulla"
|
||||
],
|
||||
"friends": [
|
||||
{
|
||||
"id": 0,
|
||||
"name": "Mamie Wyatt"
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Alejandra Mcdaniel"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
`
|
||||
|
||||
export default x
|
||||
Reference in new issue
Block a user