Skip to content

Commit

Permalink
Developed theme.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brannon Hall committed Jun 21, 2021
1 parent 7548cad commit 4f88624
Show file tree
Hide file tree
Showing 6 changed files with 304 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
124 changes: 124 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions package.json
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"
}
}
102 changes: 73 additions & 29 deletions sample/sample.js
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')}`);
Binary file modified screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 78 additions & 0 deletions src/index.js
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,
};

0 comments on commit 4f88624

Please sign in to comment.