Wondering what’s next for npm?Check out our public roadmap! »

    web-chalk

    1.1.0 • Public • Published

    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

    Install

    npm i web-chalk

    DownloadsWeekly Downloads

    3

    Version

    1.1.0

    License

    ISC

    Last publish

    Collaborators

    • avatar