decohexmessages
v0.1.5
Published
Npm module that creates custom and personalized messages with decorators through a json file.
Downloads
3
Maintainers
Readme
decohexmessages
🍭 Creates your own custom and personalized messages through a json file.
Install
npm i decohexmessages
# or "yarn add decohexmessages"
Usage
Create a example.json
with this example options
{
"exampleMessage": {
"decorator": {
"type": "curly",
"text": "success",
"color": "#06d6a0",
"foreground": "#fff"
},
"content": {
"background": "#000",
"foreground": "#fff"
}
}
}
Create an example.js file to see the simplicity of this package
const { decohexbuilder } = require('decohexmessages');
const { exampleMessage } = decohexbuilder('./example.json');
exampleMessage.print('My first time using this awesome package');
Execute script on the command line and see the magic
node example.js
JSON Options
Colors must be in hexadecimal format and all values must be provided for the respective JSON file.
decorator
| Option | Description | Usage |
| :----------: | :------------------: | :----------------------------------------------------: |
| type
| Decorator type | brackets
[] curly
{} asterisk
* exclamation
! |
| text
| Decorator text | Custom text
|
| color
| Decorator color | #aaffcc
|
| foreground
| Decorator text color | #aaffcc
|
content
| Level | Description | Usage |
| :----------: | :----------------------: | :-------: |
| background
| Content background color | #aaffcc
|
| foreground
| Content text color | #aaffcc
|
Tutorial
Create a customMessages.json
file
{
"success": {
"decorator": {
"type": "curly",
"text": "success",
"color": "#06d6a0",
"foreground": "#fff"
},
"content": {
"background": "#000",
"foreground": "#fff"
}
},
"warning": {
"decorator": {
"type": "brackets",
"text": "#ffa314",
"color": "warning",
"foreground": "#fff"
},
"content": {
"background": "#ffff3f",
"foreground": "#d7ee5e"
}
}
}
Write this simple code to create the messages from the customMessages.json
.
const { decohexbuilder } = require('decohexmessages');
// ES6 destructuring style
const { success, warning } = decohexbuilder('./customMessages.json');
success.print('Using destructuring is much cooler!');
warning.print('Using destructuring is not a ⌨️ warning!');
// or through object property
// const messages = decohexbuilder('./customMessages.json')
// messages.success.print('This is a success message or not!')
// messages.warning.print('This is a WARNING message AHAH')
After the object destructuring you can call the object method print("your messages", "can", "contain", "multiple", "objects")
to display the custom message.