|
1 | | -<p align="center"> |
2 | | - <h2 align="center">React Super Command</h2> |
3 | | - <img src="https://i.ibb.co/FYWBRSb/Screenshot-2020-12-16-at-16-42-30.png"/><br/> |
4 | | -</p> |
| 1 | +<div style="text-align:center"> |
| 2 | + <h2>React Super Command</h2> |
| 3 | + <img width="300px" src="https://i.ibb.co/FYWBRSb/Screenshot-2020-12-16-at-16-42-30.png" alt="Commandline modal"/><br/> |
| 4 | +</div> |
5 | 5 |
|
6 | 6 | [](https://www.npmjs.com/package/react-super-cmd) [](https://standardjs.com) |
7 | 7 |
|
8 | | -The command line experience for the no-mouse generation. |
9 | | -Allow your users to seamlessly interact with your React app with a blazing fast command line. |
| 8 | +The command line experience for the no-mouse generation. A blazing fast command line to allow your users to seamlessly interact with your React app. |
10 | 9 | <br><br> |
11 | 10 | [Live demo]() |
| 11 | + |
12 | 12 | ## Installation |
13 | 13 |
|
14 | 14 | ### npm |
@@ -45,27 +45,64 @@ const App = () => { |
45 | 45 | ADD_CONTACT: { |
46 | 46 | name: 'Add', logo: <AddCircleOutlineIcon/>, shortcut: '⌘ A', callback: () => console.log('add') |
47 | 47 | }, |
48 | | - DELETE_CONTACT: { |
49 | | - name: 'Delete', logo: <RemoveCircleOutlineOutlinedIcon/>, shortcut: '⌘ D', callback: () => console.log('delete') |
50 | | - }, |
51 | 48 | }; |
52 | 49 |
|
53 | 50 | function toggleIsOpen() { |
54 | 51 | setCmdLineModal(previousState => !previousState); |
55 | 52 | }; |
56 | 53 |
|
57 | 54 | return ( |
58 | | - <CommandLineModal commands={commands} isOpen={cmdLineModal} toggleIsModalOpen={toggleIsOpen} |
59 | | - title={"Super Command"} logo={<OfflineBoltOutlined/>}/> |
| 55 | + <CommandLineModal commands={commands} |
| 56 | + isOpen={cmdLineModal} |
| 57 | + toggleIsModalOpen={toggleIsOpen} |
| 58 | + title={"Super Command"} |
| 59 | + logo={<OfflineBoltOutlined/>} |
| 60 | + noOptionsText = "No commands found. Try a different search term." |
| 61 | + /> |
60 | 62 | ); |
61 | 63 | }; |
62 | 64 |
|
63 | 65 | export default App; |
64 | 66 | ``` |
65 | 67 |
|
66 | | -## Defining commands |
| 68 | +## Props |
| 69 | +### commands |
| 70 | +Object representing the different commands to list. The key is command's name and value is another object containing command details. Example: |
| 71 | +``` |
| 72 | +const commands = { |
| 73 | + SEARCH_CONTACT: { |
| 74 | + name: 'Search', logo: <SearchOutlinedIcon/>, shortcut: 'S', callback: () => console.log('search') |
| 75 | + }, |
| 76 | + ADD_CONTACT: { |
| 77 | + name: 'Add', logo: <AddCircleOutlineIcon/>, shortcut: '⌘ A', callback: () => console.log('add') |
| 78 | + }, |
| 79 | + }; |
| 80 | +``` |
| 81 | +Command details varibales |
| 82 | + |
| 83 | +| Parameter | Type | Description | Example | |
| 84 | +| :--------- | :-------- | :---------- | :----- | |
| 85 | +| name | `string` | The text to be displayed for this command| Search |
| 86 | +| logo | `component` | Component that will be next to command's name |`<SearchOutlinedIcon/>` from Material UI| |
| 87 | +| shortcut | `string` | Shortcut text to display next to command name |⌘ S| |
| 88 | +| callback | `func` | A function callback text to be displayed for this command|function searchCallback(){<br/>console.log("search called")<br/>}| |
| 89 | + |
| 90 | +### isOpen |
| 91 | +If true, command line modal will be visible. |
| 92 | + |
| 93 | +### toggleIsModalOpen |
| 94 | +A function to be called to toggle modal state. Used to control isOpen state within the external component (e.g. `Super Command` in above example). |
| 95 | + |
| 96 | +### title |
| 97 | +The title to be displayed for the command line modal (e.g. `<App>` in above example) |
| 98 | + |
| 99 | +### logo |
| 100 | +Optional<br> |
| 101 | +A logo component to display as part of the title |
67 | 102 |
|
68 | | -`react-super-cmd` uses commands |
| 103 | +### noOptionsTest |
| 104 | +Optional<br> |
| 105 | +Text to show when no commands were found based on input search term |
69 | 106 |
|
70 | 107 | ## License |
71 | 108 |
|
|
0 commit comments