web-chalk
v1.1.0
Published
Print beautiful words on the console
Downloads
4
Readme
web-chalk
Print beautiful words on the console
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
- make a pattern of strings
var str = "\n\
██ ███████ ███████\n\
██ ██ ██ ██ ██\n\
██ ▄▄ ██ ███████ ██\n\
██ ██ ██ ██ ██\n\
██ ██ ███████ ███████ A B C\n\
"
- 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\
"
- 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)'
}
}
- 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'
}
- 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