diff --git a/README.md b/README.md index f445707..54e3aa3 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ The object includes following coloring functions: `black`, `red`, `green`, `yell console.log(`I see a ${pc.red("red door")} and I want it painted ${pc.black("black")}`) ``` -The object also includes following background color modifier functions: `bgBlack`, `bgRed`, `bgGreen`, `bgYellow`, `bgBlue`, `bgMagenta`, `bgCyan`, `bgWhite`. +The object also includes following background color modifier functions: `bgBlack`, `bgRed`, `bgGreen`, `bgYellow`, `bgBlue`, `bgMagenta`, `bgCyan`, `bgWhite` and bright variants `bgBlackBright`, `bgRedBright`, `bgGreenBright`, `bgYellowBright`, `bgBlueBright`, `bgMagentaBright`, `bgCyanBright`, `bgWhiteBright`. ```javascript console.log( @@ -114,7 +114,7 @@ console.log( ) ``` -Besides colors, the object includes following formatting functions: `dim`, `bold`, `hidden`, `italic`, `underline`, `strikethrough`, `reset`, `inverse`. +Besides colors, the object includes following formatting functions: `dim`, `bold`, `hidden`, `italic`, `underline`, `strikethrough`, `reset`, `inverse` and bright variants `blackBright`, `redBright`, `greenBright`, `yellowBright`, `blueBright`, `magentaBright`, `cyanBright`, `whiteBright`. ```javascript for (let task of tasks) { diff --git a/picocolors.js b/picocolors.js index 8b8a23e..f5ea2a1 100644 --- a/picocolors.js +++ b/picocolors.js @@ -41,6 +41,7 @@ let createColors = (enabled = isColorSupported) => { inverse: init("\x1b[7m", "\x1b[27m"), hidden: init("\x1b[8m", "\x1b[28m"), strikethrough: init("\x1b[9m", "\x1b[29m"), + black: init("\x1b[30m", "\x1b[39m"), red: init("\x1b[31m", "\x1b[39m"), green: init("\x1b[32m", "\x1b[39m"), @@ -50,6 +51,7 @@ let createColors = (enabled = isColorSupported) => { cyan: init("\x1b[36m", "\x1b[39m"), white: init("\x1b[37m", "\x1b[39m"), gray: init("\x1b[90m", "\x1b[39m"), + bgBlack: init("\x1b[40m", "\x1b[49m"), bgRed: init("\x1b[41m", "\x1b[49m"), bgGreen: init("\x1b[42m", "\x1b[49m"), @@ -58,6 +60,24 @@ let createColors = (enabled = isColorSupported) => { bgMagenta: init("\x1b[45m", "\x1b[49m"), bgCyan: init("\x1b[46m", "\x1b[49m"), bgWhite: init("\x1b[47m", "\x1b[49m"), + + blackBright: init("\x1b[90m", "\x1b[39m"), + redBright: init("\x1b[91m", "\x1b[39m"), + greenBright: init("\x1b[92m", "\x1b[39m"), + yellowBright: init("\x1b[93m", "\x1b[39m"), + blueBright: init("\x1b[94m", "\x1b[39m"), + magentaBright: init("\x1b[95m", "\x1b[39m"), + cyanBright: init("\x1b[96m", "\x1b[39m"), + whiteBright: init("\x1b[97m", "\x1b[39m"), + + bgBlackBright: init("\x1b[100m","\x1b[49m"), + bgRedBright: init("\x1b[101m","\x1b[49m"), + bgGreenBright: init("\x1b[102m","\x1b[49m"), + bgYellowBright: init("\x1b[103m","\x1b[49m"), + bgBlueBright: init("\x1b[104m","\x1b[49m"), + bgMagentaBright: init("\x1b[105m","\x1b[49m"), + bgCyanBright: init("\x1b[106m","\x1b[49m"), + bgWhiteBright: init("\x1b[107m","\x1b[49m"), } } diff --git a/tests/test.js b/tests/test.js index 3bc7f58..04c99a7 100644 --- a/tests/test.js +++ b/tests/test.js @@ -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"], @@ -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"], @@ -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", () => { diff --git a/types.ts b/types.ts index b4bacee..8046e27 100644 --- a/types.ts +++ b/types.ts @@ -2,6 +2,7 @@ export type Formatter = (input: string | number | null | undefined) => string export interface Colors { isColorSupported: boolean + reset: Formatter bold: Formatter dim: Formatter @@ -10,6 +11,7 @@ export interface Colors { inverse: Formatter hidden: Formatter strikethrough: Formatter + black: Formatter red: Formatter green: Formatter @@ -19,6 +21,7 @@ export interface Colors { cyan: Formatter white: Formatter gray: Formatter + bgBlack: Formatter bgRed: Formatter bgGreen: Formatter @@ -27,4 +30,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 + }