Skip to content

Commit

Permalink
feat: bright colors variants (#55)
Browse files Browse the repository at this point in the history
* feat: bright colors variants

* docs: update readme.md
  • Loading branch information
MHase authored Jun 25, 2024
1 parent 9dd71a0 commit 1d7a86d
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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) {
Expand Down
20 changes: 20 additions & 0 deletions picocolors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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"),
Expand All @@ -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"),
}
}

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
22 changes: 22 additions & 0 deletions types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export type Formatter = (input: string | number | null | undefined) => string

export interface Colors {
isColorSupported: boolean

reset: Formatter
bold: Formatter
dim: Formatter
Expand All @@ -10,6 +11,7 @@ export interface Colors {
inverse: Formatter
hidden: Formatter
strikethrough: Formatter

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

bgBlack: Formatter
bgRed: Formatter
bgGreen: Formatter
Expand All @@ -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

}

0 comments on commit 1d7a86d

Please sign in to comment.