mirror of
https://github.com/ritz078/transform.git
synced 2026-12-03 05:29:53 +03:00
use fuzzy picker
This commit is contained in:
1 parent
b354a34db6
commit
94f82f81bc
8 files changed
+252
-181
No files matched your search
@@ -514,11 +514,11 @@ export default class ConversionPanel extends PureComponent {
|
||||
<h4 className='title'>{leftTitle}</h4>
|
||||
|
||||
{leftMode === 'json' &&
|
||||
showFetchButton && (
|
||||
<button className='btn' onClick={this.fetchJSON}>
|
||||
{fetchButtonText}
|
||||
</button>
|
||||
)}
|
||||
showFetchButton && (
|
||||
<button className='btn' onClick={this.fetchJSON}>
|
||||
{fetchButtonText}
|
||||
</button>
|
||||
)}
|
||||
|
||||
{prettierParsers[leftMode] && (
|
||||
<button
|
||||
@@ -541,43 +541,44 @@ export default class ConversionPanel extends PureComponent {
|
||||
)}
|
||||
|
||||
{extensions &&
|
||||
extensions.length > 0 && (
|
||||
<label htmlFor='upload' className='btn upload-wrapper'>
|
||||
<input
|
||||
id='upload'
|
||||
accept={extensions.join(',')}
|
||||
onChange={this.loadFile}
|
||||
type='file'
|
||||
/>
|
||||
<UploadIcon />
|
||||
</label>
|
||||
)}
|
||||
extensions.length > 0 && (
|
||||
<label htmlFor='upload' className='btn upload-wrapper'>
|
||||
<input
|
||||
id='upload'
|
||||
accept={extensions.join(',')}
|
||||
onChange={this.loadFile}
|
||||
type='file'
|
||||
/>
|
||||
<UploadIcon />
|
||||
</label>
|
||||
)}
|
||||
</div>
|
||||
{splitLeft &&
|
||||
isBrowser && (
|
||||
<div className='panel'>
|
||||
<div className='header'>
|
||||
<h4 className='title'>{splitTitle}</h4>
|
||||
{prettierParsers[splitMode] && (
|
||||
<button
|
||||
className={this.getPrettifyClass()}
|
||||
onClick={this.prettifySplitCode}
|
||||
>
|
||||
Prettify
|
||||
</button>
|
||||
)}
|
||||
isBrowser && (
|
||||
<div className='panel'>
|
||||
<div className='header'>
|
||||
<h4 className='title'>{splitTitle}</h4>
|
||||
{prettierParsers[splitMode] && (
|
||||
<button
|
||||
className={this.getPrettifyClass()}
|
||||
onClick={this.prettifySplitCode}
|
||||
>
|
||||
Prettify
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<CodeMirror
|
||||
onChange={(editor, metadata, value) =>
|
||||
this.onChange(this.state.value, value)
|
||||
}
|
||||
value={splitValue}
|
||||
options={{
|
||||
mode: modeMapping[splitMode] || splitMode,
|
||||
...codeMirrorOptions
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<CodeMirror
|
||||
onChange={(editor, metadata, value) =>
|
||||
this.onChange(this.state.value, value)}
|
||||
value={splitValue}
|
||||
options={{
|
||||
mode: modeMapping[splitMode] || splitMode,
|
||||
...codeMirrorOptions
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
)}
|
||||
</div>
|
||||
<div className='section right'>
|
||||
<div className='panel'>
|
||||
|
||||
+24
-19
@@ -5,7 +5,7 @@ import Head from 'next/head'
|
||||
import NProgress from 'nprogress'
|
||||
import Router from 'next/router'
|
||||
import GithubCorner from 'react-github-corner'
|
||||
// import FuzzyPicker, { FuzzyWrapper } from 'react-fuzzy-picker'
|
||||
import FuzzyPicker, { FuzzyWrapper } from 'react-fuzzy-picker'
|
||||
import Collapse, { Panel } from 'rc-collapse'
|
||||
import findIndex from 'lodash/findIndex'
|
||||
import { categorizedRoutes, routes, activeRouteData } from '../utils/routes'
|
||||
@@ -81,24 +81,24 @@ function trackingScript () {
|
||||
ga('send', 'pageview')
|
||||
}
|
||||
|
||||
// function renderFuzzyPicker (isOpen, onClose) {
|
||||
// return (
|
||||
// <FuzzyPicker
|
||||
// isOpen={isOpen}
|
||||
// onClose={onClose}
|
||||
// onChange={choice => Router.push(choice.path)}
|
||||
// items={routes}
|
||||
// itemValue={item => item.label}
|
||||
// renderItem={item => <span>{item.label}</span>}
|
||||
// />
|
||||
// )
|
||||
// }
|
||||
//
|
||||
// // Here, we check what key must be pressed to open the fuzzy picker
|
||||
// // We'll use the '/' key for this example.
|
||||
// function isCorrectKeyPressed (event) {
|
||||
// return event.metaKey && event.key === 'p'
|
||||
// }
|
||||
function renderFuzzyPicker (isOpen, onClose) {
|
||||
return (
|
||||
<FuzzyPicker
|
||||
isOpen={isOpen}
|
||||
onClose={onClose}
|
||||
onChange={choice => Router.push(choice.path)}
|
||||
items={routes}
|
||||
itemValue={item => item.label}
|
||||
renderItem={item => <span>{item.label}</span>}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
// Here, we check what key must be pressed to open the fuzzy picker
|
||||
// We'll use the '/' key for this example.
|
||||
function isCorrectKeyPressed (event) {
|
||||
return event.metaKey && event.key === 'p'
|
||||
}
|
||||
|
||||
export default class Layout extends PureComponent {
|
||||
state = {}
|
||||
@@ -307,6 +307,11 @@ export default class Layout extends PureComponent {
|
||||
}
|
||||
`}</style>
|
||||
|
||||
<FuzzyWrapper
|
||||
isKeyPressed={isCorrectKeyPressed}
|
||||
popup={renderFuzzyPicker}
|
||||
/>
|
||||
|
||||
<div className='sidebar'>
|
||||
<GithubCorner
|
||||
href='https://github.com/ritz078/transform-www'
|
||||
|
||||
Reference in new issue
Block a user