Skip to content

Commit

Permalink
Add bright/light colors, closes #128
Browse files Browse the repository at this point in the history
  • Loading branch information
DABH committed Sep 22, 2019
1 parent b4d964b commit 56de9f0
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 5 deletions.
22 changes: 22 additions & 0 deletions README.md
Expand Up @@ -29,6 +29,16 @@ Please check out the [roadmap](ROADMAP.md) for upcoming features and releases.
- gray
- grey

### bright text colors

- brightRed
- brightGreen
- brightYellow
- brightBlue
- brightMagenta
- brightCyan
- brightWhite

### background colors

- bgBlack
Expand All @@ -39,6 +49,18 @@ Please check out the [roadmap](ROADMAP.md) for upcoming features and releases.
- bgMagenta
- bgCyan
- bgWhite
- bgGray
- bgGrey

### bright background colors

- bgBrightRed
- bgBrightGreen
- bgBrightYellow
- bgBrightBlue
- bgBrightMagenta
- bgBrightCyan
- bgBrightWhite

### styles

Expand Down
1 change: 1 addition & 0 deletions examples/normal-usage.js
Expand Up @@ -29,6 +29,7 @@ console.log('Background color attack!'.black.bgWhite);
console.log('Use random styles on everything!'.random);
console.log('America, Heck Yeah!'.america);

console.log('Blindingly '.brightCyan + 'bright? '.brightRed + 'Why '.brightYellow + 'not?!'.brightGreen);

console.log('Setting themes is useful');

Expand Down
2 changes: 2 additions & 0 deletions examples/safe-string.js
Expand Up @@ -28,6 +28,8 @@ console.log(colors.black.bgWhite('Background color attack!'));
console.log(colors.random('Use random styles on everything!'));
console.log(colors.america('America, Heck Yeah!'));

console.log(colors.brightCyan('Blindingly ') + colors.brightRed('bright? ') + colors.brightYellow('Why ') + colors.brightGreen('not?!'));

console.log('Setting themes is useful');

//
Expand Down
3 changes: 2 additions & 1 deletion lib/maps/random.js
@@ -1,6 +1,7 @@
module['exports'] = function(colors) {
var available = ['underline', 'inverse', 'grey', 'yellow', 'red', 'green',
'blue', 'white', 'cyan', 'magenta'];
'blue', 'white', 'cyan', 'magenta', 'brightYellow', 'brightRed',
'brightGreen', 'brightBlue', 'brightWhite', 'brightCyan', 'brightMagenta'];
return function(letter, i, exploded) {
return letter === ' ' ? letter :
colors[
Expand Down
18 changes: 18 additions & 0 deletions lib/styles.js
Expand Up @@ -48,6 +48,14 @@ var codes = {
gray: [90, 39],
grey: [90, 39],

brightRed: [91, 39],
brightGreen: [92, 39],
brightYellow: [93, 39],
brightBlue: [94, 39],
brightMagenta: [95, 39],
brightCyan: [96, 39],
brightWhite: [97, 39],

bgBlack: [40, 49],
bgRed: [41, 49],
bgGreen: [42, 49],
Expand All @@ -56,6 +64,16 @@ var codes = {
bgMagenta: [45, 49],
bgCyan: [46, 49],
bgWhite: [47, 49],
bgGray: [100, 49],
bgGrey: [100, 49],

bgBrightRed: [101, 49],
bgBrightGreen: [102, 49],
bgBrightYellow: [103, 49],
bgBrightBlue: [104, 49],
bgBrightMagenta: [105, 49],
bgBrightCyan: [106, 49],
bgBrightWhite: [107, 49],

// legacy styles for colors pre v1.0.0
blackBG: [40, 49],
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "colors",
"description": "get colors in your node.js console",
"version": "1.3.4",
"version": "1.4.0",
"author": "Marak Squires",
"contributors": [
{
Expand Down
13 changes: 12 additions & 1 deletion tests/basic-test.js
Expand Up @@ -16,7 +16,10 @@ function aE(s, color, code) {
}

var stylesColors = ['white', 'black', 'blue', 'cyan', 'green', 'magenta',
'red', 'yellow'];
'red', 'yellow', 'brightYellow', 'brightRed',
'brightGreen', 'brightBlue', 'brightWhite', 'brightCyan',
'brightMagenta'];

// eslint-disable-next-line
var stylesAll = stylesColors.concat(['bold', 'italic', 'underline',
'inverse', 'rainbow']);
Expand Down Expand Up @@ -46,6 +49,14 @@ aE(s, 'magenta', 35);
aE(s, 'red', 31);
aE(s, 'yellow', 33);

aE(s, 'brightWhite', 97);
aE(s, 'brightBlue', 94);
aE(s, 'brightCyan', 96);
aE(s, 'brightGreen', 92);
aE(s, 'brightMagenta', 95);
aE(s, 'brightRed', 91);
aE(s, 'brightYellow', 93);

assert.equal(s, 'string');

var testStringWithNewLines = s + '\n' + s;
Expand Down
12 changes: 11 additions & 1 deletion tests/safe-test.js
Expand Up @@ -13,7 +13,9 @@ function aE(s, color, code) {
}

var stylesColors = ['white', 'black', 'blue', 'cyan', 'green', 'magenta',
'red', 'yellow'];
'red', 'yellow', 'brightYellow', 'brightRed',
'brightGreen', 'brightBlue', 'brightWhite', 'brightCyan',
'brightMagenta'];
// eslint-disable-next-line
var stylesAll = stylesColors.concat(['bold', 'italic', 'underline', 'inverse',
'rainbow']);
Expand All @@ -37,6 +39,14 @@ aE(s, 'magenta', 35);
aE(s, 'red', 31);
aE(s, 'yellow', 33);

aE(s, 'brightWhite', 97);
aE(s, 'brightBlue', 94);
aE(s, 'brightCyan', 96);
aE(s, 'brightGreen', 92);
aE(s, 'brightMagenta', 95);
aE(s, 'brightRed', 91);
aE(s, 'brightYellow', 93);

assert.equal(s, 'string');

var testStringWithNewLines = s + '\n' + s;
Expand Down

0 comments on commit 56de9f0

Please sign in to comment.