fluident
Version:
A simple JavaScript package to add custom colors, gradients, and styles to your console logs.
175 lines (135 loc) • 4.56 kB
Markdown
# 🎨 fluident
**fluident** is a simple npm package for adding beautiful colors, gradients, and styles to your console output.
It leverages **ANSI escape codes**, ensuring compatibility with most modern terminals.
## 🚀 Installation
Install the package using **npm**:
```bash
npm install fluident
```
## 💻 Usage
Import the package into your JavaScript file and start styling your console logs:
```js
const fluident = require('fluident');
// Basic usage
console.log(fluident.blue('This is a blue message.'));
```
**Output:**
*(Displays "This is a blue message." in blue)*
You can also **chain methods** for multiple effects:
```js
const fluident = require('fluident');
console.log(
fluident.bold(
fluident.underline(
fluident.cyan('This message is bold, underlined, and cyan.')
)
)
);
```
## ✨ Basic Styles
| Style Name | Example Code |
|------------------|-------------------------------------------|
| **bold** | `fluident.bold('text')` |
| **dim** | `fluident.dim('text')` |
| **italic** | `fluident.italic('text')` |
| **underline** | `fluident.underline('text')` |
| **inverse** | `fluident.inverse('text')` |
| **hidden** | `fluident.hidden('text')` |
| **strikethrough**| `fluident.strikethrough('text')` |
| **reset** | `fluident.reset('text')` |
## 🎨 Standard Colors
| Color Name | Example Code |
|-----------|-----------------------------|
| **black** | `fluident.black('text')` |
| **red** | `fluident.red('text')` |
| **green** | `fluident.green('text')` |
| **yellow** | `fluident.yellow('text')` |
| **blue** | `fluident.blue('text')` |
| **magenta** | `fluident.magenta('text')` |
| **cyan** | `fluident.cyan('text')` |
| **white** | `fluident.white('text')` |
| **gray** | `fluident.gray('text')` |
## 🖌️ Background Colors
| Background Color | Example Code |
|------------------|----------------------------------|
| **bgBlack** | `fluident.bgBlack('text')` |
| **bgRed** | `fluident.bgRed('text')` |
| **bgGreen** | `fluident.bgGreen('text')` |
| **bgYellow** | `fluident.bgYellow('text')` |
| **bgBlue** | `fluident.bgBlue('text')` |
| **bgMagenta** | `fluident.bgMagenta('text')` |
| **bgCyan** | `fluident.bgCyan('text')` |
| **bgWhite** | `fluident.bgWhite('text')` |
| **bgGray** | `fluident.bgGray('text')` |
## 🔥 Advanced Usage
### 🌈 True Colors (24-bit)
#### `fluident.hex(hexColor)`
Applies a **true color** using a HEX code:
```js
console.log(fluident.hex('#FF5733')('This is a custom hex color.'));
```
#### `fluident.rgb(r, g, b)`
Applies a **true color** using RGB values:
```js
console.log(fluident.rgb(255, 0, 128)('This is a custom RGB color.'));
```
### 🌈 Gradients
Create horizontal or vertical gradients for your text.
```js
fluident.gradient(text, hexColors, direction)
```
| Parameter | Description |
|------------------|------------------------------------------------------------|
| `text` | The text to apply the gradient to. |
| `hexColors` | Array of HEX color strings (e.g. `['#ff0000', '#0000ff']`).|
| `direction` | `'horizontal'` (default) or `'vertical'`. |
#### Horizontal Gradient Example:
```js
const myGradient = fluident.gradient(
'Horizontal Rainbow!',
['#ff0000', '#ffff00', '#00ff00', '#0000ff']
);
console.log(myGradient);
```
#### Vertical Gradient Example:
```js
const verticalText = `
V
e
r
t
i
c
a
l
`;
const myVerticalGradient = fluident.gradient(
verticalText,
['#ff0000', '#0000ff'],
'vertical'
);
console.log(myVerticalGradient);
```
## ASCII Art
The `ascii` method converts your text into a blocky font suitable for console output.
```js
fl.ascii(text)
```
- `text` *(string)*: The text to convert.
### Example
```js
const fl = require('fluident');
const asciiArt = fl.ascii('Hello');
console.log(fl.green(asciiArt));
```
## 📝 License
Licensed under the **ISC License**.