-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ad121e
commit 5aef050
Showing
48 changed files
with
555 additions
and
47 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
.docz/.cache/caches/gatsby-plugin-mdx/diskstore-2e753b5d99f243ee25545e87329a0d2d.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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;"}} |
Oops, something went wrong.