Skip to content

Commit

Permalink
feat: bright colors variants
Browse files Browse the repository at this point in the history
  • Loading branch information
MHase committed Aug 15, 2023
1 parent 6b43e8e commit 658a2ae
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
20 changes: 20 additions & 0 deletions picocolors.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ let createColors = (enabled = isColorSupported) => ({
inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,

black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
Expand All @@ -44,6 +45,7 @@ let createColors = (enabled = isColorSupported) => ({
cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,

bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
Expand All @@ -52,6 +54,24 @@ let createColors = (enabled = isColorSupported) => ({
bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String,

blackBright: enabled ? formatter("\x1b[90m", "\x1b[39m"): String,
redBright: enabled ? formatter("\x1b[91m", "\x1b[39m"): String,
greenBright: enabled ? formatter("\x1b[92m", "\x1b[39m"): String,
yellowBright: enabled ? formatter("\x1b[93m", "\x1b[39m"): String,
blueBright: enabled ? formatter("\x1b[94m", "\x1b[39m"): String,
magentaBright: enabled ? formatter("\x1b[95m", "\x1b[39m"): String,
cyanBright: enabled ? formatter("\x1b[96m", "\x1b[39m"): String,
whiteBright: enabled ? formatter("\x1b[97m", "\x1b[39m"): String,

bgBlackBright: enabled ? formatter("\x1b[100m","\x1b[49m"): String,
bgRedBright: enabled ? formatter("\x1b[101m","\x1b[49m"): String,
bgGreenBright: enabled ? formatter("\x1b[102m","\x1b[49m"): String,
bgYellowBright: enabled ? formatter("\x1b[103m","\x1b[49m"): String,
bgBlueBright: enabled ? formatter("\x1b[104m","\x1b[49m"): String,
bgMagentaBright: enabled ? formatter("\x1b[105m","\x1b[49m"): String,
bgCyanBright: enabled ? formatter("\x1b[106m","\x1b[49m"): String,
bgWhiteBright: enabled ? formatter("\x1b[107m","\x1b[49m"): String,
})

module.exports = createColors()
Expand Down
20 changes: 20 additions & 0 deletions tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const FMT = {
inverse: ["\x1b[7m", "\x1b[27m"],
hidden: ["\x1b[8m", "\x1b[28m"],
strikethrough: ["\x1b[9m", "\x1b[29m"],

black: ["\x1b[30m", "\x1b[39m"],
red: ["\x1b[31m", "\x1b[39m"],
green: ["\x1b[32m", "\x1b[39m"],
Expand All @@ -19,6 +20,7 @@ const FMT = {
cyan: ["\x1b[36m", "\x1b[39m"],
white: ["\x1b[37m", "\x1b[39m"],
gray: ["\x1b[90m", "\x1b[39m"],

bgBlack: ["\x1b[40m", "\x1b[49m"],
bgRed: ["\x1b[41m", "\x1b[49m"],
bgGreen: ["\x1b[42m", "\x1b[49m"],
Expand All @@ -27,6 +29,24 @@ const FMT = {
bgMagenta: ["\x1b[45m", "\x1b[49m"],
bgCyan: ["\x1b[46m", "\x1b[49m"],
bgWhite: ["\x1b[47m", "\x1b[49m"],

blackBright: ["\x1b[90m", "\x1b[39m"],
redBright: ["\x1b[91m", "\x1b[39m"],
greenBright: ["\x1b[92m", "\x1b[39m"],
yellowBright: ["\x1b[93m", "\x1b[39m"],
blueBright: ["\x1b[94m", "\x1b[39m"],
magentaBright: ["\x1b[95m", "\x1b[39m"],
cyanBright: ["\x1b[96m", "\x1b[39m"],
whiteBright: ["\x1b[97m", "\x1b[39m"],

bgBlackBright: ["\x1b[100m","\x1b[49m"],
bgRedBright: ["\x1b[101m","\x1b[49m"],
bgGreenBright: ["\x1b[102m","\x1b[49m"],
bgYellowBright: ["\x1b[103m","\x1b[49m"],
bgBlueBright: ["\x1b[104m","\x1b[49m"],
bgMagentaBright: ["\x1b[105m","\x1b[49m"],
bgCyanBright: ["\x1b[106m","\x1b[49m"],
bgWhiteBright: ["\x1b[107m","\x1b[49m"],
}

test("color matching", () => {
Expand Down
21 changes: 21 additions & 0 deletions types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface Colors {
inverse: Formatter
hidden: Formatter
strikethrough: Formatter

black: Formatter
red: Formatter
green: Formatter
Expand All @@ -19,6 +20,7 @@ export interface Colors {
cyan: Formatter
white: Formatter
gray: Formatter

bgBlack: Formatter
bgRed: Formatter
bgGreen: Formatter
Expand All @@ -27,4 +29,23 @@ export interface Colors {
bgMagenta: Formatter
bgCyan: Formatter
bgWhite: Formatter

blackBright: Formatter
redBright: Formatter
greenBright: Formatter
yellowBright: Formatter
blueBright: Formatter
magentaBright: Formatter
cyanBright: Formatter
whiteBright: Formatter

bgBlackBright: Formatter
bgRedBright: Formatter
bgGreenBright: Formatter
bgYellowBright: Formatter
bgBlueBright: Formatter
bgMagentaBright: Formatter
bgCyanBright: Formatter
bgWhiteBright: Formatter

}

0 comments on commit 658a2ae

Please sign in to comment.