1.1.0 • Published 6 months ago

concolor v1.1.0

Weekly downloads
155
License
MIT
Repository
github
Last release
6 months ago

Concolor

ci status snyk npm version npm downloads/month npm downloads

Concolor is a simple library for Node.js for coloring templated strings using tags with annotations

Usage

String tag

console.log(concolor`text ${expression}(styles)`);

Examples:

console.log(concolor`Ave ${'World'}(blue) blue`);
console.log(concolor`Ave ${'World'}(/red) on red`);
console.log(concolor`Ave ${'World'}(white/yellow,b) bold white on yellow`);
console.log(concolor`Ave ${'World'}(b) bold`);
console.log(concolor`Ave ${'World'}(b,/blue) bold on blue`);
console.log(concolor`Ave ${'World'}(b,u,yellow) bold underline yellow`);
console.log(concolor`Ave ${'World'}(blue,u) blue underline`);
console.log(concolor`Ave ${'World'}(b,black/green) bold black on green`);

console.log(concolor`
  Client on ${'192.168.1.1'}(black/green)
  connected to ${'SERVER'}(b,red)
  at ${new Date().toUTCString()}(b,blue)
`);

Tag factory

const tag = concolor(styles);
console.log(tag`text`);

Examples:

const warn = concolor('b,yellow');
const err = concolor('b,yellow/red');
const inf = concolor('i,white');

console.log(warn`test1 ${'text2'} text3`);
console.log(err`test4 ${'text5'} text6`);
console.log(inf`test7 ${'text8'} text9`);

Style function

const style = concolor(styles);
console.log(style('text'));

Examples:

const warn = concolor('b,yellow');
const err = concolor('b,yellow/red');
const inf = concolor('i,white');

console.log(warn(`test1 ${'text2'} text3`));
console.log(err(`test4 ${'text5'} text6`));
console.log(inf(`test7 ${'text8'} text9`));

Themes

const theme = concolor({
  caption: 'b,white',
  text: 'green',
  link: 'u,yellow',
});

const caption = 'Caption';
const text = 'Here is a text';
const link = 'http://metarhia.com';

console.log(theme`  ${{ caption }}
  ${{ text }}
  ${{ link }}`);

Themes as functions

const theme = concolor({
  caption: 'b,white',
  text: 'green',
  link: 'u,yellow',
});

console.log(theme.caption('Caption example'));

License & Contributors

Copyright (c) 2017-2023 Metarhia contributors. Concolor is MIT licensed.\ Concolor is a part of Metarhia technology stack.

1.1.0

6 months ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

2 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.1.16

4 years ago

0.1.15

4 years ago

0.1.14

4 years ago

0.1.13

5 years ago

0.1.12

5 years ago

0.1.11

5 years ago

0.1.10

5 years ago

0.1.9

6 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.0

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago