Skip to content

Commit

Permalink
Add prop and public member documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
astralarya committed May 27, 2016
1 parent 2691534 commit c8a9a8b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Inspired by [chrisdone/jquery-console](https://github.com/chrisdone/jquery-conso

## Example

```javascript
import ReactConsole from 'react-console';
Simple prompt that echoes back input:

```javascript
let EchoPrompt = React.createClass({
echo: function(text) {
this.console.log(text);
Expand All @@ -18,3 +18,25 @@ let EchoPrompt = React.createClass({
}
});
```

## Props

Properties you can pass to the console element

| Prop | Type | Description
| ---- | ---- | ----
| autofocus | bool | Autofocus the console on component mount.
| cancel | function() | Function that should stop execution of the current command and call `this.return()`.
| complete | function(words: string[], cursor: number, prompt: string): string[] | Return a list of possible completions given a list of (`words`), index of the word containing the cursor (`cursor`) , and the full prompt text (`prompt`).
| continue | function(prompt: string): bool | Return a boolean indicating whether to continue asking for user input on a newline given the current prompt text (`prompt`).
| handler | function(command: string): void | Handle a command (`command`), logging data with `this.log()` or `this.logX()`, and calling `this.return()` when finished.
| promptLabel | string | String displayed to prompt user for input.
| welcomeMessage | string | Initial message displayed after mount.

## Public members

| Member | Type | Description
| ---- | ---- | ----
| log | function(...messages: any): void | Log messages to the console. If string, print the value, otherwise, print the JSON value of the message.
| logX | function(type: string, ...messages: any): void | Log messages of a particular type to the console. The messages will be given the class `react-console-message-{type}`.
| return | function(): void | Signal the current command has finished and a new prompt should be displayed.
2 changes: 1 addition & 1 deletion src/react-console.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ module.exports = React.createClass({
}
}
},
cancelExecution: function() {
cancelExecution: function() { // TODO link this handle
this.props.cancel();
},
commandTrigger: function() {
Expand Down

0 comments on commit c8a9a8b

Please sign in to comment.