Skip to content

Commit

Permalink
Add more styles and improve formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcralph committed Feb 25, 2021
1 parent 0f306a3 commit 0f4c071
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ See the [documentation](https://docs.derpyenterprises.org/#/leeks)

[Stack Overflow](https://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb) - Hex support

and all the contributors <3
and all the contributors!
2 changes: 2 additions & 0 deletions lib/data/Colours.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
enum colours {
// Default
black = 30,
red = 31,
green = 32,
Expand All @@ -17,6 +18,7 @@ enum colours {
magentaBright = 95,
cyanBright = 96,
whiteBright = 97,
// Background
bgBlack = 40,
bgRed = 41,
bgGreen = 42,
Expand Down
4 changes: 4 additions & 0 deletions lib/data/Styles.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
enum styles {
reset = 0,
// Styles
bold = 1,
dim = 2,
italic = 3,
underline = 4,
overline = 53,
blink = 5,
inverse = 7,
strikethrough = 9,
hidden = 8,
shown = 28,
// Remove styles
nostrikethrough = 29,
nounderline = 24,
nooverline = 55,
noblink = 25,
noinverse = 27
}
Expand Down
2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ for (let s in Styles) styles[s] = (t: string) => `\x1b[${Styles[s]}m${t}\x1b[0m`
* Check if colours are supported.
* @credit [Colorette](https://github.com/jorgebucaran/colorette)
*/
let supports:string | boolean = !('NO_COLOR' in process.env) && process.env.FORCE_COLOR !== '0' && (process.env.FORCE_COLOR || process.platform === 'win32' || (process.stdout.isTTY && process.env.TERM && process.env.TERM !== 'dumb'));
let supports: string | boolean = !('NO_COLOR' in process.env) && process.env.FORCE_COLOR !== '0' && (process.env.FORCE_COLOR || process.platform === 'win32' || (process.stdout.isTTY && process.env.TERM && process.env.TERM !== 'dumb'));

/**
* Change the colour of the given text using 8-bit colours.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
"256"
],
"devDependencies": {
"@types/node": "^14.14.16"
"@types/node": "^14.14.31"
}
}
8 changes: 4 additions & 4 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ console.log(leeks.colors.blue(leeks.styles.underline('Hello!')));
console.log(leeks.colours.grey('Hello!'));
console.log(leeks.colors.gray('Hello!'));

console.log(leeks.eightBit('32', 'hello'));
console.log(leeks.eightBitBg('32', 'hello'));
console.log(leeks.eightBit(32, 'hello'));
console.log(leeks.eightBitBg(32, 'hello'));

console.log(leeks.rgb(['114', '137', '218'], 'hello'));
console.log(leeks.rgbBg(['114', '137', '218'], 'hello'));
console.log(leeks.rgb([114, 137, 218], 'hello'));
console.log(leeks.rgbBg([114, 137, 218], 'hello'));

console.log(leeks.hex('#7289da', 'hello'));
console.log(leeks.hexBg('#7289da', 'hello'));

0 comments on commit 0f4c071

Please sign in to comment.