0.1.5 • Published 3 years ago

decohexmessages v0.1.5

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

decohexmessages

🍭 Creates your own custom and personalized messages through a json file.

npm package npm package last commit

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

OptionDescriptionUsage
typeDecorator typebrackets [] curly {} asterisk * exclamation !
textDecorator textCustom text
colorDecorator color#aaffcc
foregroundDecorator text color#aaffcc

content

LevelDescriptionUsage
backgroundContent background color#aaffcc
foregroundContent 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.