feat: add gradient and theme features with corresponding tests and documentation
This commit is contained in:
parent
aa06bb5ac3
commit
c017dd5b04
8 changed files with 505 additions and 13 deletions
34
examples/theme.js
Normal file
34
examples/theme.js
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import chalk from '../source/index.js';
|
||||
|
||||
// Set color level to enable colors (adjust based on terminal support)
|
||||
chalk.level = 3;
|
||||
|
||||
// Define a custom theme with named styles
|
||||
const themedChalk = chalk.theme({
|
||||
error: chalk.red.bold,
|
||||
success: chalk.green,
|
||||
warning: chalk.yellow.underline,
|
||||
info: chalk.blue,
|
||||
title: chalk.magenta.bold.underline,
|
||||
});
|
||||
|
||||
// Demonstrate the theme in action
|
||||
console.log(themedChalk.title('Chalk Theme Example'));
|
||||
console.log(); // Empty line
|
||||
|
||||
console.log(themedChalk.error('This is an error message'));
|
||||
console.log(themedChalk.success('This is a success message'));
|
||||
console.log(themedChalk.warning('This is a warning message'));
|
||||
console.log(themedChalk.info('This is an info message'));
|
||||
console.log(); // Empty line
|
||||
|
||||
// Show that original styles still work
|
||||
console.log(themedChalk.red('Still works with original styles'));
|
||||
console.log(themedChalk.bold('Bold text from themed chalk'));
|
||||
|
||||
// Demonstrate chaining with theme styles
|
||||
console.log(themedChalk.error.bgWhite('Error on white background'));
|
||||
console.log(themedChalk.success.underline('Underlined success'));
|
||||
|
||||
console.log();
|
||||
console.log(themedChalk.title('Theme Complete!'));
|
||||
Loading…
Add table
Add a link
Reference in a new issue