generated from dracula/template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Brannon Hall
committed
Jun 21, 2021
1 parent
7548cad
commit 4f88624
Showing
6 changed files
with
304 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "dracula-console", | ||
"version": "0.1.0", | ||
"description": "Dracula theme for Node console", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"test": "node sample/sample.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/brannonh/dracula-console.git" | ||
}, | ||
"keywords": [ | ||
"dark-theme" | ||
], | ||
"author": { | ||
"name": "brannonh", | ||
"email": "[email protected]" | ||
}, | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/brannonh/dracula-console/issues" | ||
}, | ||
"homepage": "https://github.com/brannonh/dracula-console#readme", | ||
"dependencies": { | ||
"chalk": "^4.1.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,73 @@ | ||
/* | ||
* Once upon a time... | ||
*/ | ||
|
||
class Vampire { | ||
constructor(props) { | ||
this.location = props.location; | ||
this.birthDate = props.birthDate; | ||
this.deathDate = props.deathDate; | ||
this.weaknesses = props.weaknesses; | ||
} | ||
|
||
get age() { | ||
return this.calcAge(); | ||
} | ||
|
||
calcAge() { | ||
return this.deathDate - this.birthDate; | ||
} | ||
} | ||
|
||
// ...there was a guy named Vlad | ||
|
||
const Dracula = new Vampire({ | ||
location: 'Transylvania', | ||
birthDate: 1428, | ||
deathDate: 1476, | ||
weaknesses: ['Sunlight', 'Garlic'] | ||
}); | ||
const dracula = require('../src'); | ||
|
||
// Banner | ||
console.log(); | ||
console.log( | ||
dracula.purple('Dracula Theme'), | ||
dracula.fg('for'), | ||
dracula.green('Node'), | ||
dracula.fg('Console'), | ||
`${dracula.fg('(')}${dracula.pink('No Background')}${dracula.fg(')')}` | ||
); | ||
|
||
// Samples | ||
console.log(` [foreground] ${dracula.fg('How vexingly quick daft zebras jump!')}`); | ||
console.log(` [comment] ${dracula.comment('How vexingly quick daft zebras jump!')}`); | ||
console.log(` [cyan] ${dracula.cyan('How vexingly quick daft zebras jump!')}`); | ||
console.log(` [green] ${dracula.green('How vexingly quick daft zebras jump!')}`); | ||
console.log(` [orange] ${dracula.orange('How vexingly quick daft zebras jump!')}`); | ||
console.log(` [pink] ${dracula.pink('How vexingly quick daft zebras jump!')}`); | ||
console.log(` [purple] ${dracula.purple('How vexingly quick daft zebras jump!')}`); | ||
console.log(` [red] ${dracula.red('How vexingly quick daft zebras jump!')}`); | ||
console.log(` [yellow] ${dracula.yellow('How vexingly quick daft zebras jump!')}`); | ||
|
||
// Banner | ||
console.log(); | ||
console.log( | ||
dracula.purple('Dracula Theme'), | ||
dracula.fg('for'), | ||
dracula.green('Node'), | ||
dracula.fg('Console'), | ||
`${dracula.fg('(')}${dracula.pink('With Background')}${dracula.fg(')')}` | ||
); | ||
|
||
// Config | ||
dracula.set('useBg', true); | ||
|
||
// Samples | ||
console.log(` [foreground] ${dracula.fg('How vexingly quick daft zebras jump!')}`); | ||
console.log(` [comment] ${dracula.comment('How vexingly quick daft zebras jump!')}`); | ||
console.log(` [cyan] ${dracula.cyan('How vexingly quick daft zebras jump!')}`); | ||
console.log(` [green] ${dracula.green('How vexingly quick daft zebras jump!')}`); | ||
console.log(` [orange] ${dracula.orange('How vexingly quick daft zebras jump!')}`); | ||
console.log(` [pink] ${dracula.pink('How vexingly quick daft zebras jump!')}`); | ||
console.log(` [purple] ${dracula.purple('How vexingly quick daft zebras jump!')}`); | ||
console.log(` [red] ${dracula.red('How vexingly quick daft zebras jump!')}`); | ||
console.log(` [yellow] ${dracula.yellow('How vexingly quick daft zebras jump!')}`); | ||
|
||
// Config | ||
dracula.set('useBg', false); | ||
|
||
// Banner | ||
console.log(); | ||
console.log( | ||
dracula.purple('Dracula Theme'), | ||
dracula.fg('for'), | ||
dracula.green('Node'), | ||
dracula.fg('Console'), | ||
`${dracula.fg('(')}${dracula.pink('With')} ${dracula.cyan('Current / Selected')} ${dracula.pink('Background')}${dracula.fg(')')}` | ||
); | ||
|
||
// Config | ||
dracula.set('useBg', true); | ||
|
||
// Samples | ||
console.log(` [foreground] ${dracula.fg('How vexingly quick daft zebras jump!', 'current')}`); | ||
console.log(` [comment] ${dracula.comment('How vexingly quick daft zebras jump!', 'selected')}`); | ||
console.log(` [cyan] ${dracula.cyan('How vexingly quick daft zebras jump!', 'current')}`); | ||
console.log(` [green] ${dracula.green('How vexingly quick daft zebras jump!', 'selected')}`); | ||
console.log(` [orange] ${dracula.orange('How vexingly quick daft zebras jump!', 'current')}`); | ||
console.log(` [pink] ${dracula.pink('How vexingly quick daft zebras jump!', 'selected')}`); | ||
console.log(` [purple] ${dracula.purple('How vexingly quick daft zebras jump!', 'current')}`); | ||
console.log(` [red] ${dracula.red('How vexingly quick daft zebras jump!', 'selected')}`); | ||
console.log(` [yellow] ${dracula.yellow('How vexingly quick daft zebras jump!', 'current')}`); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
const chalk = require('chalk'); | ||
|
||
const options = { | ||
useBg: false, | ||
} | ||
|
||
const bgStates = { | ||
background: '#282a36', | ||
current: '#44475a', | ||
selected: '#44475a', | ||
} | ||
|
||
function set(option, value) { | ||
if (Object.keys(options).includes(option)) { | ||
options[option] = value; | ||
} | ||
} | ||
|
||
function stylize(text, fgColor, bgState = 'background') { | ||
let f = chalk.hex(fgColor); | ||
if (options.useBg === true) { | ||
const bgColor = Object.keys(bgStates).includes(bgState) ? bgStates[bgState] : bgState.background; | ||
f = f.bgHex(bgColor); | ||
} | ||
|
||
return f(text); | ||
} | ||
|
||
function foreground(text, bgState = 'background') { | ||
return stylize(text, '#f8f8f2', bgState); | ||
} | ||
const fg = foreground; | ||
|
||
function comment(text, bgState = 'background') { | ||
return stylize(text, '#6272a4', bgState); | ||
} | ||
|
||
function cyan(text, bgState = 'background') { | ||
return stylize(text, '#8be9fd', bgState); | ||
} | ||
|
||
function green(text, bgState = 'background') { | ||
return stylize(text, '#50fa7b', bgState); | ||
} | ||
|
||
function orange(text, bgState = 'background') { | ||
return stylize(text, '#ffb86c', bgState); | ||
} | ||
|
||
function pink(text, bgState = 'background') { | ||
return stylize(text, '#ff79c6', bgState); | ||
} | ||
|
||
function purple(text, bgState = 'background') { | ||
return stylize(text, '#bd93f9', bgState); | ||
} | ||
|
||
function red(text, bgState = 'background') { | ||
return stylize(text, '#ff5555', bgState); | ||
} | ||
|
||
function yellow(text, bgState = 'background') { | ||
return stylize(text, '#f1fa8c', bgState); | ||
} | ||
|
||
module.exports = { | ||
set, | ||
foreground, | ||
fg, | ||
comment, | ||
cyan, | ||
green, | ||
orange, | ||
pink, | ||
purple, | ||
red, | ||
yellow, | ||
}; |