Skip to content

Commit 9165241

Browse files
committed
Update documentation
1 parent 50b5eac commit 9165241

File tree

2 files changed

+51
-14
lines changed

2 files changed

+51
-14
lines changed

README.md

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
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>
55

66
[![NPM](https://img.shields.io/npm/v/react-super-cmd.svg)](https://www.npmjs.com/package/react-super-cmd) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
77

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.
109
<br><br>
1110
[Live demo]()
11+
1212
## Installation
1313

1414
### npm
@@ -45,27 +45,64 @@ const App = () => {
4545
ADD_CONTACT: {
4646
name: 'Add', logo: <AddCircleOutlineIcon/>, shortcut: '⌘ A', callback: () => console.log('add')
4747
},
48-
DELETE_CONTACT: {
49-
name: 'Delete', logo: <RemoveCircleOutlineOutlinedIcon/>, shortcut: '⌘ D', callback: () => console.log('delete')
50-
},
5148
};
5249

5350
function toggleIsOpen() {
5451
setCmdLineModal(previousState => !previousState);
5552
};
5653

5754
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+
/>
6062
);
6163
};
6264

6365
export default App;
6466
```
6567

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
67102

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
69106

70107
## License
71108

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const useStyles = (theme) => ({
5151

5252
const CommandLineModal = ({
5353
classes, commands, isOpen, toggleIsModalOpen, title,
54-
noOptionsText = "No command found. Try a different search term.",
54+
noOptionsText = "No commands found. Try a different search term.",
5555
logo = <OfflineBoltOutlined/>
5656
}) => {
5757
let commandsInternal = {};

0 commit comments

Comments
 (0)