Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
PondWader committed Jun 30, 2024
0 parents commit 8670cfa
Show file tree
Hide file tree
Showing 14 changed files with 1,799 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .c8rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"reporter": [
"lcov"
],
"exclude": [
"dist/test"
]
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
node_modules
coverage
10 changes: 10 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"bracketSpacing": false,
"printWidth": 80,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none",
"useTabs": false,
"arrowParens": "always"
}
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
MIT License

Copyright (c) 2024 PondWader

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
106 changes: 106 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# picospinner

<img src="assets/demo.gif" width="522" alt="Demo">

A lightweight, no dependency, pluggable CLI spinner library.

## Install

```
npm i picospinner
```

## Usage

### Basic

```js
import {Spinner} from 'picospinner';

const spinner = new Spinner('Loading...');
spinner.start();
setTimeout(() => {
spinner.succeed('Finished.');
}, 5000);
```

### Custom symbols

```js
import {Spinner} from 'picospinner';

const spinner = new Spinner('Loading...', {
symbols: {
warn: ''
}
});
spinner.start();
setTimeout(() => {
spinner.warn("Something didn't go quite right.");
}, 5000);
```

### Custom frames

```js
import {Spinner} from 'picospinner';

const spinner = new Spinner('Loading...', {
frames: ['-', '\\', '|', '/']
});
spinner.start();
setTimeout(() => {
spinner.info('Finished.');
}, 5000);
```

### Removing the spinner

Calling `spinner.stop();` will stop the spinner and remove it.

### Colours

Colours can be achieved by using a formatter such as picocolors or chalk. First install picocolors:

```
npm i picocolors
```

Text can be formatted by passing pre-formatted text:

```js
import {Spinner} from 'picospinner';
import pc from 'picocolors';

const spinner = new Spinner(pc.blue('Loading...'));
spinner.start();
setTimeout(() => spinner.setText(pc.magenta("Now it's magenta!")), 1000);
```

Symbols can be formatted by passing a symbol formatter.

```js
import {Spinner} from 'picospinner';
import pc from 'picocolors';

const spinner = new Spinner({
text: pc.blue('Loading...'),
symbolFormatter: pc.green
});
spinner.start();
spinner.fail({
text: 'Disaster!',
symbolFormatter: pc.red
});
```

### Custom rotation speed

A custom tick speed (how often the spinner rotates) in milliseconds can be passed to `spinner.start`:

```js
import {Spinner} from 'picospinner';

const spinner = new Spinner();
spinner.start(10);
```
Binary file added assets/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 8670cfa

Please sign in to comment.