mirror of
https://github.com/ritz078/transform.git
synced 2026-11-25 10:14:22 +03:00
fixes
This commit is contained in:
1 parent
daf4dee5b6
commit
99a3f85097
5 files changed
+29
-15
No files matched your search
@@ -1,7 +1,6 @@
|
||||
import React, { PureComponent } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import Router from 'next/router'
|
||||
import { transform } from 'babel-standalone'
|
||||
import isBrowser from 'is-in-browser'
|
||||
import { js_beautify } from 'js-beautify'
|
||||
import { beauty } from 'css-beauty'
|
||||
@@ -12,9 +11,9 @@ const theme = 'tomorrow'
|
||||
let brace
|
||||
let AceEditor
|
||||
if (isBrowser) {
|
||||
window.babelTransform = transform
|
||||
brace = require('brace').default
|
||||
AceEditor = require('react-ace').default
|
||||
|
||||
require('brace/mode/javascript')
|
||||
require(`brace/theme/${theme}`)
|
||||
require('brace/mode/json')
|
||||
@@ -26,8 +25,7 @@ export default class ConversionPanel extends PureComponent {
|
||||
static propTypes = {
|
||||
name: PropTypes.string.isRequired,
|
||||
leftMode: PropTypes.string,
|
||||
rightMode: PropTypes.string,
|
||||
pathname: PropTypes.string
|
||||
rightMode: PropTypes.string
|
||||
}
|
||||
|
||||
static defaultProps = {
|
||||
@@ -55,6 +53,11 @@ 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)
|
||||
@@ -137,7 +140,7 @@ export default class ConversionPanel extends PureComponent {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.section {
|
||||
.section {
|
||||
flex: 1;
|
||||
position: relative;
|
||||
height: calc(100vh - 50px);
|
||||
@@ -148,6 +151,18 @@ export default class ConversionPanel extends PureComponent {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1000px) {
|
||||
.content-wrapper {
|
||||
flex-direction: column;
|
||||
}
|
||||
.section {
|
||||
height: auto;
|
||||
}
|
||||
.right {
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
}
|
||||
|
||||
.error {
|
||||
color: red;
|
||||
font: 14px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
|
||||
|
||||
@@ -6,6 +6,8 @@ import NProgress from 'nprogress'
|
||||
import Router from 'next/router'
|
||||
import GithubCorner from 'react-github-corner'
|
||||
|
||||
NProgress.configure({ showSpinner: false })
|
||||
|
||||
Router.onRouteChangeStart = (url) => {
|
||||
if(url.indexOf('code=') === -1) {
|
||||
NProgress.start()
|
||||
@@ -122,7 +124,7 @@ export default function ({children, pathname}) {
|
||||
font-size: 12px;
|
||||
position: absolute;
|
||||
margin-top: 6px;
|
||||
margin-left: 4px;
|
||||
margin-left: 6px;
|
||||
background-color: #2196f3;
|
||||
height: 13px;
|
||||
padding: 2px 4px;
|
||||
|
||||
+2
-3
@@ -2,8 +2,7 @@ import React, { PureComponent } from 'react'
|
||||
import dynamic from 'next/dynamic'
|
||||
import plugin from '../utils/css-to-js'
|
||||
import Layout from '../components/Layout'
|
||||
|
||||
const ConversionPanel = dynamic(import('../components/ConversionPanel'))
|
||||
import ConversionPanel from '../components/ConversionPanel'
|
||||
|
||||
const defaultText = `
|
||||
.abc {
|
||||
@@ -11,7 +10,7 @@ const defaultText = `
|
||||
}
|
||||
`
|
||||
|
||||
export default class Main extends PureComponent {
|
||||
export default class Css2Js extends PureComponent {
|
||||
getTransformedValue = (newValue) => {
|
||||
return plugin(newValue)
|
||||
}
|
||||
|
||||
+3
-4
@@ -1,10 +1,9 @@
|
||||
import React, { PureComponent } from 'react'
|
||||
import plugin from '../utils/babel-plugin-js-to-prop-types'
|
||||
|
||||
import dynamic from 'next/dynamic'
|
||||
import Layout from '../components/Layout'
|
||||
import { transform } from 'babel-standalone'
|
||||
|
||||
const ConversionPanel = dynamic(import('../components/ConversionPanel'))
|
||||
import ConversionPanel from '../components/ConversionPanel'
|
||||
|
||||
const defaultText = `// Enter the object you want to convert in the
|
||||
// following form
|
||||
@@ -21,7 +20,7 @@ const x = {
|
||||
|
||||
export default class Main extends PureComponent {
|
||||
getTransformedValue = (newValue) => {
|
||||
const {code} = babelTransform(newValue, {
|
||||
const {code} = transform(newValue, {
|
||||
presets: ['es2015'],
|
||||
plugins: [plugin]
|
||||
})
|
||||
|
||||
@@ -2,8 +2,7 @@ import React, { PureComponent } from 'react'
|
||||
import dynamic from 'next/dynamic'
|
||||
import { Json2dts, toValidJSON } from 'json2dts'
|
||||
import Layout from '../components/Layout'
|
||||
|
||||
const ConversionPanel = dynamic(import('../components/ConversionPanel'))
|
||||
import ConversionPanel from '../components/ConversionPanel'
|
||||
|
||||
const defaultText = `
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user