GithubHelp home page GithubHelp logo

metarhia / concolor Goto Github PK

View Code? Open in Web Editor NEW
44.0 14.0 0.0 434 KB

Colouring template strings using tags with annotations ๐ŸŽจ

Home Page: https://metarhia.com

License: MIT License

JavaScript 100.00%
color colors metarhia impress nodejs javascript console ansi

concolor's Introduction

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.

concolor's People

Contributors

aqrln avatar dependabot[bot] avatar juliagerasymenko avatar primeare avatar tshemsedinov avatar volchinskiy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

concolor's Issues

Add default styles

concolor.em, concolor.success, concolor.fail, concolor.b, concolor.red etc.

Use tag as a function

Now concolor have 2 different syntax:

// String tag:
console.log(concolor`text ${expression}(styles)`);

// Tag factory:
const tag = concolor(styles);
console.log(tag`text`);

But we need another additional usage syntax:

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

Use theme tags as functions

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

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

Implement themes

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.