added fuzzy search

This commit is contained in:
Ritesh Kumar committed 2017-08-26 13:57:33 +05:30
1 parent 21fc03ae01
commit e7aec70db1
5 files changed
+224 -81

No files matched your search

+1 -2
View File
@@ -165,7 +165,6 @@ export default class ConversionPanel extends PureComponent {
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.6.14/beautify-css.js" />
<style jsx>{`
@import url('https://fonts.googleapis.com/css?family=Lato');
.wrapper {
display: flex;
flex: 1;
@@ -179,7 +178,7 @@ export default class ConversionPanel extends PureComponent {
font-family: 'Lato';
background-color: white;
box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.2);
z-index: 999;
z-index: 99;
display: flex;
align-items: center;
text-align: center;
+81 -38
View File
@@ -5,6 +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";
NProgress.configure({ showSpinner: false });
@@ -16,37 +17,48 @@ Router.onRouteChangeStart = url => {
Router.onRouteChangeComplete = () => NProgress.done();
Router.onRouteChangeError = () => NProgress.done();
const routes = [{
label: 'JSON to React PropTypes',
path: '/'
}, {
label: 'JSON to Flow Types',
path: '/json-to-flow-types'
}, {
label: 'JSON to Typescript Interface',
path: '/json-to-ts-interface'
}, {
label: 'JSON to MobX-State-Tree Model',
path: '/json-to-mobx-state-tree'
}, {
label: 'CSS to JS Objects',
path: '/css-to-js'
}, {
label: 'HTML to JSX',
path: '/html-to-jsx'
}, {
label: 'JSON to Rust Serde',
path: '/json-to-rust-serde'
}, {
label: 'JSON to Mongoose Schema',
path: '/json-to-mongoose'
}, {
label: "JSON to Big Query Schema",
path: "/json-to-big-query"
}, {
label: "JSON to MySQL",
path: "/json-to-mysql"
}]
const routes = [
{
label: "JSON to React PropTypes",
path: "/"
},
{
label: "JSON to Flow Types",
path: "/json-to-flow-types",
},
{
label: "JSON to Typescript Interface",
path: "/json-to-ts-interface"
},
{
label: "JSON to MobX-State-Tree Model",
path: "/json-to-mobx-state-tree"
},
{
label: "CSS to JS Objects",
path: "/css-to-js"
},
{
label: "HTML to JSX",
path: "/html-to-jsx"
},
{
label: "JSON to Rust Serde",
path: "/json-to-rust-serde"
},
{
label: "JSON to Mongoose Schema",
path: "/json-to-mongoose"
},
{
label: "JSON to Big Query Schema",
path: "/json-to-big-query"
},
{
label: "JSON to MySQL",
path: "/json-to-mysql"
}
];
function Logo() {
return (
@@ -85,6 +97,28 @@ 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";
}
export default function({ children, pathname }) {
function getClass(path) {
return path === pathname ? "active" : "";
@@ -98,7 +132,10 @@ export default function({ children, pathname }) {
rel="description"
content="An online utility to convert a JSON object to prop-types, Typescript Interface, Rust serde or flow types. It also converts your CSS into JS and HTML into JSX."
/>
<meta name="google-site-verification" content="bjJSOEahdert-7mwVScrwTTUVR3nSe0bEj5YjevUNn0" />
<meta
name="google-site-verification"
content="bjJSOEahdert-7mwVScrwTTUVR3nSe0bEj5YjevUNn0"
/>
<link rel="icon" type="image/png" href="/static/favicon.png" />
<link rel="stylesheet" type="text/css" href="/static/nprogress.css" />
</Head>
@@ -199,6 +236,10 @@ export default function({ children, pathname }) {
}
`}</style>
<FuzzyWrapper
isKeyPressed={isCorrectKeyPressed}
popup={renderFuzzyPicker}
/>
<div className="sidebar">
<GithubCorner
href="https://github.com/ritz078/transform-www"
@@ -210,13 +251,15 @@ export default function({ children, pathname }) {
<Logo />
</div>
<ul>
{routes.map(route => (
{routes.map(route =>
<li key={route.path} className={getClass(route.path)}>
<Link prefetch href={route.path}>
<a>{route.label}</a>
</Link>
</li>
))}
<Link prefetch href={route.path}>
<a>
{route.label}
</a>
</Link>
</li>
)}
</ul>
<div className="footer">
+2
View File
@@ -30,7 +30,9 @@
"prop-types": "^15.5.10",
"react": "^15.6.1",
"react-ace": "^5.1.2",
"react-collapsible": "^2.0.0",
"react-dom": "^15.6.1",
"react-fuzzy-picker": "^0.5.1",
"react-github-corner": "^0.3.0",
"stringify-object": "^3.2.0",
"webpack-bundle-analyzer": "^2.9.0"
+115 -39
View File
@@ -1,74 +1,150 @@
@import url('https://fonts.googleapis.com/css?family=Lato');
/* Make clicks pass-through */
#nprogress {
pointer-events: none;
pointer-events: none;
}
#nprogress .bar {
background: #29d;
background: #29d;
position: fixed;
z-index: 1031;
top: 0;
left: 0;
position: fixed;
z-index: 1031;
top: 0;
left: 0;
width: 100%;
height: 2px;
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;
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);
-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;
display: block;
position: fixed;
z-index: 1031;
top: 15px;
right: 15px;
}
#nprogress .spinner-icon {
width: 18px;
height: 18px;
box-sizing: border-box;
width: 18px;
height: 18px;
box-sizing: border-box;
border: solid 2px transparent;
border-top-color: #29d;
border-left-color: #29d;
border-radius: 50%;
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;
-webkit-animation: nprogress-spinner 400ms linear infinite;
animation: nprogress-spinner 400ms linear infinite;
}
.nprogress-custom-parent {
overflow: hidden;
position: relative;
overflow: hidden;
position: relative;
}
.nprogress-custom-parent #nprogress .spinner,
.nprogress-custom-parent #nprogress .bar {
position: absolute;
position: absolute;
}
@-webkit-keyframes nprogress-spinner {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
}
@keyframes nprogress-spinner {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.fuzzy-picker-background {
background: rgba(0, 0, 0, 0.1);
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
display: flex;
align-items: flex-start;
justify-content: center;
padding-top: 300px;
padding-top: 25vh;
z-index: 100;
font-family: 'Lato';
}
.fuzzy-picker-background .fuzzy-picker {
width: 600px;
background: #fff;
border-radius: 2px;
box-shadow: 0px 0px 16px #333;
font-size: 1rem;
display: flex;
flex-direction: column;
}
.fuzzy-picker-background .fuzzy-picker .fuzzy-picker-top-text {
color: #aaa;
margin-top: 0.5em;
margin-left: 0.5rem;
margin-right: 0.5rem;
font-size: 16px;
user-select: none;
}
.fuzzy-picker-background .fuzzy-picker .fuzzy-picker-top-text .fuzzy-picker-label {
float: left;
}
.fuzzy-picker-background .fuzzy-picker .fuzzy-picker-top-text .fuzzy-picker-instructions {
float: right;
}
.fuzzy-picker-background .fuzzy-picker .fuzzy-picker-top-text .fuzzy-picker-instructions span {
margin: 0.35em;
}
.fuzzy-picker-background .fuzzy-picker input[type=text] {
border: 1px solid #dedede;
border-radius: 2px;
outline: none;
flex: 1;
font-size: 18px;
padding: 4px;
margin: 0.5rem;
margin-bottom: 0;
}
.fuzzy-picker-background .fuzzy-picker ul {
list-style-type: none;
padding-left: 0px;
margin-top: 0.2em;
margin-bottom: 0.5em;
}
.fuzzy-picker-background .fuzzy-picker ul li {
margin: 0.1em 0.5rem;
padding: 0.6em 0.5em;
border-radius: 2px;
cursor: pointer;
}
.fuzzy-picker-background .fuzzy-picker ul li.selected {
background-color: #444444;
color: #fff;
}
+25 -2
View File
@@ -1208,6 +1208,10 @@ cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3:
inherits "^2.0.1"
safe-buffer "^5.0.1"
classnames@^2.2.5:
version "2.2.5"
resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.2.5.tgz#fb3801d453467649ef3603c7d61a02bd129bde6d"
cli-cursor@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5"
@@ -1996,6 +2000,10 @@ function-bind@^1.0.2, function-bind@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.0.tgz#16176714c801798e4e8f2cf7f7529467bb4a5771"
fuzzysearch@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/fuzzysearch/-/fuzzysearch-1.0.3.tgz#dffc80f6d6b04223f2226aa79dd194231096d008"
gauge@~2.7.3:
version "2.7.4"
resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7"
@@ -3355,11 +3363,19 @@ react-ace@^5.1.2:
opencollective "^1.0.3"
prop-types "^15.5.8"
react-collapsible@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/react-collapsible/-/react-collapsible-2.0.0.tgz#a98113bb26ab55fc5ed95a4835c3fbf8cbf973af"
dependencies:
prop-types "^15.5.8"
react "^15.5.4"
react-dom "^15.5.4"
react-deep-force-update@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/react-deep-force-update/-/react-deep-force-update-2.0.1.tgz#4f7f6c12c3e7de42f345992a3c518236fa1ecad3"
react-dom@^15.6.1:
react-dom@^15.5.4, react-dom@^15.6.1:
version "15.6.1"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-15.6.1.tgz#2cb0ed4191038e53c209eb3a79a23e2a4cf99470"
dependencies:
@@ -3376,6 +3392,13 @@ react-dom@~15.4.1:
loose-envify "^1.1.0"
object-assign "^4.1.0"
react-fuzzy-picker@^0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/react-fuzzy-picker/-/react-fuzzy-picker-0.5.1.tgz#28668dff21352cc980611b252e66b88d6af4ad8d"
dependencies:
classnames "^2.2.5"
fuzzysearch "^1.0.3"
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"
@@ -3397,7 +3420,7 @@ react-proxy@^3.0.0-alpha.0:
dependencies:
lodash "^4.6.1"
react@^15.6.1:
react@^15.5.4, react@^15.6.1:
version "15.6.1"
resolved "https://registry.yarnpkg.com/react/-/react-15.6.1.tgz#baa8434ec6780bde997cdc380b79cd33b96393df"
dependencies: