# slim-bot

> Module for adding command features to an input field

Latest version **0.3.0** (published 2016-12-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install slim-bot
pnpm add slim-bot
yarn add slim-bot
bun add slim-bot
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2016-12-05 |
| First published | 2016-12-04 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | David Diefenderfer |
| Maintainers | ddiefenderfer |
| Keywords | ES6, slim, command, bot |

## Links

- npm: https://www.npmjs.com/package/slim-bot
- Repository: https://github.com/daviddiefenderfer/slim-bot
- Homepage: https://github.com/daviddiefenderfer/slim-bot#readme
- Issues: https://github.com/daviddiefenderfer/slim-bot/issues
- npm.io page: https://npm.io/package/slim-bot

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 0.3.0 (latest) — 2016-12-05
- 0.2.3 — 2016-12-05
- 0.2.2 — 2016-12-05
- 0.2.1 — 2016-12-05
- 0.2.0 — 2016-12-05
- 0.1.2 — 2016-12-04
- 0.1.1 — 2016-12-04
- 0.1.0 — 2016-12-04

## README

##Slim-bot

Module for adding command features to an input field

Attaches an event listener to the provided input element. When prefix is entered,
input gets `.console-mode` class and starts listening for commands

##Installation

`npm install slim-bot`

##Usage

HTML
```html
<!-- Element to listen to -->
<input type="text" id="input-element" />
```

CSS
```css
/* Class that gets applied when input enters console-mode */
.console-mode {
    background-color: lightred;
}
```

JS
```js
// Import Tokenize from slim-bot
const Tokenize = require('slim-bot');

// Define HTMLInputElement
const inputElement = document.getElementById('input-element');

// Define commands
const myCommands = {
  'open': {
      params: ['Enter a URL or path'],
      operation: function(path) {
          window.open(path);
      }
  },
  'backgroundColor': {
      params: ['Enter a hex code'],
      operation: function(color) {
          document.body.style.backgroundColor = color;
      }
  },
  'big': {
      params: [],
      operation: function() {
          input.blur();
          input.classList.add('big');
          setTimeout(function() {
            input.classList.remove('big');
            input.focus();
          }, 1000);
      }
   }
};

// Instantiate Tokenize
const slimBot = new Tokenize({
    commands: myCommands,
    element: inputElement,
    prefix: '/'
});

```

##Demo
Play around with the demo
`git clone https://github.com/daviddiefenderfer/slim-bot.git && cd slim-bot/demo && npm start`

App served at localhost:8080

---
_Source: https://npm.io/package/slim-bot · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
