Skip to content

Commit

Permalink
added README and updated docz
Browse files Browse the repository at this point in the history
  • Loading branch information
pranesh239 committed Feb 9, 2020
1 parent 9ad121e commit 5aef050
Show file tree
Hide file tree
Showing 48 changed files with 555 additions and 47 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion .docz/.cache/api-runner-browser-plugins.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .docz/.cache/async-requires.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
const preferDefault = m => m && m.default || m

exports.components = {
"component---cache-dev-404-page-js": () => import("./dev-404-page.js" /* webpackChunkName: "component---cache-dev-404-page-js" */),
"component---docs-index-mdx": () => import("./../../docs/index.mdx" /* webpackChunkName: "component---docs-index-mdx" */),
"component---docs-pages-demo-mdx": () => import("./../../docs/pages/demo.mdx" /* webpackChunkName: "component---docs-pages-demo-mdx" */),
"component---docs-pages-props-mdx": () => import("./../../docs/pages/props.mdx" /* webpackChunkName: "component---docs-pages-props-mdx" */),
"component---src-pages-404-js": () => import("./../src/pages/404.js" /* webpackChunkName: "component---src-pages-404-js" */)
}

16 changes: 8 additions & 8 deletions .docz/.cache/babelState.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
{
"name": "/Users/pranesh.g/Documents/opensource/use-key-capture-2/node_modules/@emotion/babel-preset-css-prop/dist/babel-preset-css-prop.cjs.js",
"options": {
"sourceMap": false,
"autoLabel": false,
"sourceMap": true,
"autoLabel": true,
"plugins": []
}
}
Expand All @@ -45,8 +45,8 @@
{
"name": "/Users/pranesh.g/Documents/opensource/use-key-capture-2/node_modules/@emotion/babel-preset-css-prop/dist/babel-preset-css-prop.cjs.js",
"options": {
"sourceMap": false,
"autoLabel": false,
"sourceMap": true,
"autoLabel": true,
"plugins": []
}
}
Expand All @@ -73,8 +73,8 @@
{
"name": "/Users/pranesh.g/Documents/opensource/use-key-capture-2/node_modules/@emotion/babel-preset-css-prop/dist/babel-preset-css-prop.cjs.js",
"options": {
"sourceMap": false,
"autoLabel": false,
"sourceMap": true,
"autoLabel": true,
"plugins": []
}
}
Expand All @@ -101,8 +101,8 @@
{
"name": "/Users/pranesh.g/Documents/opensource/use-key-capture-2/node_modules/@emotion/babel-preset-css-prop/dist/babel-preset-css-prop.cjs.js",
"options": {
"sourceMap": false,
"autoLabel": false,
"sourceMap": true,
"autoLabel": true,
"plugins": []
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"expireTime":9007200835964219000,"key":"gatsby-plugin-mdx-entire-payload-85368e6469d8f4c3d4545b15dd192ff6-","val":{"mdast":{"type":"root","children":[{"type":"import","value":"import DefaultLayout from \"/Users/pranesh.g/Documents/opensource/use-key-capture-2/node_modules/gatsby-theme-docz/src/base/Layout.js\"","position":{"start":{"line":3,"column":1,"offset":2},"end":{"line":3,"column":134,"offset":135},"indent":[]}},{"type":"export","default":true,"value":"export default DefaultLayout","position":{"start":{"line":5,"column":1,"offset":137},"end":{"line":5,"column":29,"offset":165},"indent":[]}},{"type":"import","value":"import { Playground } from 'docz';\nimport GlobalComponent from '../Components/GlobalEventComponent.js';\nimport TargetEventComponent from '../Components/TargetEventComponent.js';","position":{"start":{"line":8,"column":1,"offset":168},"end":{"line":10,"column":74,"offset":345},"indent":[1,1]}},{"type":"heading","depth":2,"children":[{"type":"text","value":"Target Listener","position":{"start":{"line":12,"column":4,"offset":350},"end":{"line":12,"column":19,"offset":365},"indent":[]}}],"position":{"start":{"line":12,"column":1,"offset":347},"end":{"line":12,"column":19,"offset":365},"indent":[]}},{"type":"paragraph","children":[{"type":"text","value":"Listen only for the key-press event for a particular target.","position":{"start":{"line":14,"column":1,"offset":367},"end":{"line":14,"column":61,"offset":427},"indent":[]}}],"position":{"start":{"line":14,"column":1,"offset":367},"end":{"line":14,"column":61,"offset":427},"indent":[]}},{"type":"paragraph","children":[{"type":"text","value":"It is provided by ","position":{"start":{"line":16,"column":1,"offset":429},"end":{"line":16,"column":19,"offset":447},"indent":[]}},{"type":"inlineCode","value":"getTargetProps","position":{"start":{"line":16,"column":19,"offset":447},"end":{"line":16,"column":35,"offset":463},"indent":[]}},{"type":"text","value":" props getter. If ","position":{"start":{"line":16,"column":35,"offset":463},"end":{"line":16,"column":53,"offset":481},"indent":[]}},{"type":"inlineCode","value":"getTargetProps","position":{"start":{"line":16,"column":53,"offset":481},"end":{"line":16,"column":69,"offset":497},"indent":[]}},{"type":"text","value":" props getter is not provided, then it will listen for key-press event globally.","position":{"start":{"line":16,"column":69,"offset":497},"end":{"line":16,"column":149,"offset":577},"indent":[]}}],"position":{"start":{"line":16,"column":1,"offset":429},"end":{"line":16,"column":149,"offset":577},"indent":[]}},{"type":"code","lang":"jsx","meta":null,"value":"<input {...getTargetProps()} />","position":{"start":{"line":18,"column":1,"offset":579},"end":{"line":20,"column":4,"offset":621},"indent":[1,1]}},{"type":"jsx","value":"<TargetEventComponent />","position":{"start":{"line":22,"column":1,"offset":623},"end":{"line":22,"column":25,"offset":647},"indent":[]}},{"type":"code","lang":"jsx","meta":null,"value":"import React from 'react';\nimport useKey from 'use-key-capture';\nimport './styles.css';\n\nconst displayKeys = ['Q', 'W', 'E', 'R', 'T', 'Y', 'Backspace'];\n\nconst TargetEventComponent = () => {\n const { keyData, getTargetProps } = useKey();\n\n const getIsActive = key => (keyData.key === key ? 'active' : '');\n\n return (\n <div className=\"container-target\">\n <div className=\"message\">\n Type QWERTY in the input element below. If the focus is outside the\n target, we won't see any change.\n </div>\n <input {...getTargetProps()} />\n <div className=\"container\">\n {displayKeys.map(key => {\n return <div className={`box ${getIsActive(key)}`}>{key}</div>;\n })}\n </div>\n </div>\n );\n};\n\nexport default TargetEventComponent;","position":{"start":{"line":24,"column":1,"offset":649},"end":{"line":53,"column":4,"offset":1442},"indent":[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]}},{"type":"heading","depth":2,"children":[{"type":"text","value":"Global Listener","position":{"start":{"line":55,"column":4,"offset":1447},"end":{"line":55,"column":19,"offset":1462},"indent":[]}}],"position":{"start":{"line":55,"column":1,"offset":1444},"end":{"line":55,"column":19,"offset":1462},"indent":[]}},{"type":"paragraph","children":[{"type":"text","value":"If no target is specified, it will listen for global event.","position":{"start":{"line":57,"column":1,"offset":1464},"end":{"line":57,"column":60,"offset":1523},"indent":[]}}],"position":{"start":{"line":57,"column":1,"offset":1464},"end":{"line":57,"column":60,"offset":1523},"indent":[]}},{"type":"jsx","value":"<GlobalComponent />","position":{"start":{"line":59,"column":1,"offset":1525},"end":{"line":59,"column":20,"offset":1544},"indent":[]}},{"type":"code","lang":"jsx","meta":null,"value":"import React from 'react';\nimport useKey from 'use-key-capture';\nimport './styles.css';\n\nconst displayKeys = ['Enter', 'Escape', 'Tab', 'ArrowUp'];\n\nconst GlobalComponent = () => {\n const { keyData } = useKey();\n\n const getIsActive = key => (keyData.key === key ? 'active' : '');\n\n const getCombinedActiveClass = () =>\n keyData.key === 'A' && keyData.isWithShift ? 'active' : '';\n\n return (\n <>\n <div className=\"message\">\n Press below mentioned keys to see the hook in action\n </div>\n <div className=\"container\">\n {displayKeys.map(key => {\n return <div className={`box ${getIsActive(key)}`}>{key}</div>;\n })}\n <div className={`box ${getCombinedActiveClass()}`}>Shift + A</div>\n </div>\n </>\n );\n};\n\nexport default GlobalComponent;","position":{"start":{"line":61,"column":1,"offset":1546},"end":{"line":92,"column":4,"offset":2357},"indent":[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]}},{"type":"export","value":"export const _frontmatter = {}","position":{"start":{"line":95,"column":1,"offset":2360},"end":{"line":95,"column":31,"offset":2390},"indent":[]}}],"position":{"start":{"line":1,"column":1,"offset":0},"end":{"line":95,"column":31,"offset":2390}}},"scopeImports":[],"scopeIdentifiers":[],"rawMDXOutput":"/* @jsx mdx */\nimport { mdx } from '@mdx-js/react';\n/* @jsx mdx */\nimport DefaultLayout from \"/Users/pranesh.g/Documents/opensource/use-key-capture-2/node_modules/gatsby-theme-docz/src/base/Layout.js\"\nimport { Playground } from 'docz';\nimport GlobalComponent from '../Components/GlobalEventComponent.js';\nimport TargetEventComponent from '../Components/TargetEventComponent.js';\nexport const _frontmatter = {};\nconst makeShortcode = name => function MDXDefaultShortcode(props) {\n console.warn(\"Component \" + name + \" was not imported, exported, or provided by MDXProvider as global scope\")\n return <div {...props}/>\n};\n\nconst layoutProps = {\n _frontmatter\n};\nconst MDXLayout = DefaultLayout\nexport default function MDXContent({\n components,\n ...props\n}) {\n return <MDXLayout {...layoutProps} {...props} components={components} mdxType=\"MDXLayout\">\n\n\n\n <h2 {...{\n \"id\": \"target-listener\"\n }}>{`Target Listener`}</h2>\n <p>{`Listen only for the key-press event for a particular target.`}</p>\n <p>{`It is provided by `}<inlineCode parentName=\"p\">{`getTargetProps`}</inlineCode>{` props getter. If `}<inlineCode parentName=\"p\">{`getTargetProps`}</inlineCode>{` props getter is not provided, then it will listen for key-press event globally.`}</p>\n <pre><code parentName=\"pre\" {...{\n \"className\": \"language-jsx\"\n }}>{`<input {...getTargetProps()} />\n`}</code></pre>\n <TargetEventComponent mdxType=\"TargetEventComponent\" />\n <pre><code parentName=\"pre\" {...{\n \"className\": \"language-jsx\"\n }}>{`import React from 'react';\nimport useKey from 'use-key-capture';\nimport './styles.css';\n\nconst displayKeys = ['Q', 'W', 'E', 'R', 'T', 'Y', 'Backspace'];\n\nconst TargetEventComponent = () => {\n const { keyData, getTargetProps } = useKey();\n\n const getIsActive = key => (keyData.key === key ? 'active' : '');\n\n return (\n <div className=\"container-target\">\n <div className=\"message\">\n Type QWERTY in the input element below. If the focus is outside the\n target, we won't see any change.\n </div>\n <input {...getTargetProps()} />\n <div className=\"container\">\n {displayKeys.map(key => {\n return <div className={\\`box \\${getIsActive(key)}\\`}>{key}</div>;\n })}\n </div>\n </div>\n );\n};\n\nexport default TargetEventComponent;\n`}</code></pre>\n <h2 {...{\n \"id\": \"global-listener\"\n }}>{`Global Listener`}</h2>\n <p>{`If no target is specified, it will listen for global event.`}</p>\n <GlobalComponent mdxType=\"GlobalComponent\" />\n <pre><code parentName=\"pre\" {...{\n \"className\": \"language-jsx\"\n }}>{`import React from 'react';\nimport useKey from 'use-key-capture';\nimport './styles.css';\n\nconst displayKeys = ['Enter', 'Escape', 'Tab', 'ArrowUp'];\n\nconst GlobalComponent = () => {\n const { keyData } = useKey();\n\n const getIsActive = key => (keyData.key === key ? 'active' : '');\n\n const getCombinedActiveClass = () =>\n keyData.key === 'A' && keyData.isWithShift ? 'active' : '';\n\n return (\n <>\n <div className=\"message\">\n Press below mentioned keys to see the hook in action\n </div>\n <div className=\"container\">\n {displayKeys.map(key => {\n return <div className={\\`box \\${getIsActive(key)}\\`}>{key}</div>;\n })}\n <div className={\\`box \\${getCombinedActiveClass()}\\`}>Shift + A</div>\n </div>\n </>\n );\n};\n\nexport default GlobalComponent;\n`}</code></pre>\n\n </MDXLayout>;\n}\n\n;\nMDXContent.isMDXComponent = true;"}}
Loading

0 comments on commit 5aef050

Please sign in to comment.