0.1.6 • Published 1 year ago

prompt-ui v0.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

prompt-ui

Features

TODO

Installation

Install package with NPM or YARN and add it to your development dependencies:

npm install prompt-ui

OR

yarn add prompt-ui

Usage

import { PromptShell } from "prompt-ui";

function App(props) {
  // Define commands here
  const commands = {
    TODO
  };

  return (
    <PromptShell
      commands={commands}
    />
  );
}

Also make sure to wrap the main mount point around the PromptContextProvider. This retains the state even when the component is unmounted and then mounted back:

import { PromptContextProvider } from "prompt-ui";

ReactDOM.render(
  <PromptContextProvider>
    <App/>
  </PromptContextProvider>,
  rootElement
);

Add an HTML element to the page

Create an HTML page, or edit an existing one, and add the following within the body tags:

    <prompt TODO></prompt>
    <script src="https://unpkg.com/prompt-ui> </script>

Open the HTML file in your browser, and your prompt interface will be displayed on page.

Creating custom themes

The component comes with few in-built themes: light, dark. You can also create custom themes by passing themes parameter in props, as follows:

<PromptShell
  commands={commands}
  settings={settings}
/>

Props

namedescriptiondefault
commandsList of commands to be provided as a key value pair where value can be either a string, JSX/HTML tag or callbacknull
errorMessageMessage to show when unidentified command executed, can be either a string, JSX/HTML tag or callback"not found!"
settingsPrompt settings defining the appearance and behavior of the Prompt. This includes properties such as the prompt displayed at the beginning of input and the theme applied to the PromptShell interface. See Default Settings for default values and configurations.null

Settings

interface Settings {
  prompt: "$";
  theme: Theme;
  // TODO
}

Theme

interface Theme {
  // TODO
}

In-built commands

commanddescription
clearclears the console
historyshow last {property.historySize} inputs

Report a bug

If you found a bug in this library, please file an GitHub issue here.

0.1.6

1 year ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.0

2 years ago

0.1.0-alpha

2 years ago