Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/icodeforlove/template-colors-web
:art: beautiful color usage within template literals for console.log on the web
https://github.com/icodeforlove/template-colors-web
Last synced: 12 days ago
JSON representation
:art: beautiful color usage within template literals for console.log on the web
- Host: GitHub
- URL: https://github.com/icodeforlove/template-colors-web
- Owner: icodeforlove
- Created: 2014-03-27T23:00:56.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2019-05-20T18:42:30.000Z (over 5 years ago)
- Last Synced: 2024-10-25T06:28:33.396Z (18 days ago)
- Language: JavaScript
- Homepage:
- Size: 248 KB
- Stars: 194
- Watchers: 11
- Forks: 18
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# template-colors-web [![Build Status](https://travis-ci.org/icodeforlove/template-colors-web.png?branch=master)](https://travis-ci.org/icodeforlove/template-colors-web)
### next generation web console colors!
beautiful color usage within template literals for console.log on the web
**[LIVE INTERACTIVE DEMO](http://icodeforlove.github.io/template-colors-web/)**
## install
```
npm install --save template-colors-web
```## usage
you can compose colored template literals in many ways
```javascript
import c from 'template-colors-web';console.log(c`found ${17}.bold new users`);
console.log(c`found ${17}.bold new users`.bold.underline.grey);
console.log(c`could not delete ${6}.bold.green users`.underline.red);
console.log(c`user ${'John Doe'}.white.bold ${'logged'}.yellow in at ${new Date()}.white.bold`.grey);
console.log(c`
This is ${'a'}.blue.italic
${'multiline'}.black.magentaBG
${'example'}.bold.underline.
`.grey);
```## features
rgb / rgbBG (may be unsupported by your terminal)
```javascript
c`foo bar`.rgb(255,0,0)
c`foo bar`.rgb(255,0,0).rgbBG(0,0,0)
```inline style commands
```javascript
c`${'foo bar'}.bold.red`
```pre existing styles
```javascript
c`${'foo bar'.bold}.red`
```defalt styles to apply to whole string
```javascript
c`${'foo'}.red bar`.grey.underline
```full style support
```javascript
c`${'foo'}.red bar`.style('font-size: 100px')
```custom defined styles
```javascript
c.define('error', 'rgb(255,0,0)');
c.define('log', ['rgb(0,0,0)', 'rgbBG(255,255,255)', 'bold', 'underline', 'italic']);c`foo bar`.error
c`foo bar`.log
```## node CLI
If you would like to use template colors in your command line please check out this repo : **[template-colors](https://github.com/icodeforlove/template-colors)**