1.1.0 • Published 7 years ago

web-chalk v1.1.0

Weekly downloads
2
License
ISC
Repository
-
Last release
7 years ago

web-chalk

Print beautiful words on the console web-chalk

Installing

$ npm install web-chalk --save

Usage

ready

  • require
var webChalk = require('web-chalk');
  • or
<script src='./web-chalk.min.js' type="text/javascript"></script>

go

  1. make a pattern of strings
var str = "\n\
        ██          ███████         ███████\n\
      ██  ██        ██     ██     ██\n\
     ██ ▄▄ ██       ███████       ██\n\
    ██      ██      ██     ██     ██\n\
   ██        ██     ███████         ███████   A  B  C\n\
    "
  1. add color
var str_ = "\n\
        <b>██</b>          <r>███████</r>         <g>███████</g>\n\
      <b>██  ██</b>        <r>██     ██</r>     <g>██</g>\n\
     <b>██ ▄▄ ██</b>       <r>███████</r>       <g>██</g>\n\
    <b>██      ██</b>      <r>██     ██</r>     <g>██</g>\n\
   <b>██        ██</b>     <r>███████</r>         <g>███████</g>  <b>A</b> <r>B</r> <g>C</g>\n\
    "
  1. define the class name in a css Object, the string wrapped by the class name tag will have the color of the corresponding class name
var cssClass = {
    b: {
        color: 'rgb(29,174,229)'
    },
    bl: {
        color: 'rgb(67,81,84)'
    },
    r: {
        color: 'rgb(218,14,26)'
    },
    g: {
        color: 'rgb(171,204,3)'
    },
    gr: {
        color: 'rgb(92,104,104)'
    }
}
  1. a string that is not wrapped by a tag will use the default style, and you can also customize the default style
var defaultCss = {
  color:'gray'
}
  1. output
// params:(target[string], config[object])
// config: {style[object], default[object]?}
webChalk(str, {
    style: cssClass,
    default: defaultCss
});

If your entire string style is the same,You can omit the style parameter

webChalk(str,  {
    default: defaultCss
});

others methods

  • webChalk.log('abc')
  • webChalk.warn('abc')
  • webChalk.error('abc')
  • webChalk.info('abc')

License:

MIT

1.1.0

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago