Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support truecolor, #352 #354

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

webdiscus
Copy link

@webdiscus webdiscus commented Feb 8, 2025

I'm the author of ansis.

This PR replaces the outdated @colors/colors (last update 2 years ago) package with smaller and faster - ansis, which supports truecolor.

Changes:

  • add a syntax for using hex color in style option, Border Color #352
    For example: style: { border: ['hex(#FFD700)'], head: ['hex(#FFA500)', 'bgHex(#3d239d)'] }
  • add doumentation to the README how to use colors in tables, please see the new README
  • add tests for using colors
  • add missing test:coverage script to package.json

- replace @colors/colors with smaller, fater ansis which supports truecolor
- add a syntax for using hex color in style option
- add doumentation to the README how to use colors in tables
- add tests for using colors
- add missing test coverage script to package.json
@@ -16,6 +16,7 @@
"string-width": "^4.2.0"
},
"devDependencies": {
"@colors/colors": "1.5.0",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @colors/colors package is still required for test the legacy cli-table package in the verify-legacy-compatibility-test.js file, therefore it should be in devDependencies

for (let i = this[styleProperty].length - 1; i >= 0; i--) {
colors = colors[this[styleProperty][i]];
let style = this[styleProperty][i];
let isHex = style.startsWith('hex');
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add support for new truecolor syntax using hex code, e.g.: hex(#FFD700) and bgHex(#FFD700).

@@ -17,8 +17,8 @@ describe('utils', function () {
expect(strlen(colors.red('hello'))).toEqual(5);
});

it('length of "hello" in zebra is 5', function () {
expect(strlen(colors.zebra('hello'))).toEqual(5);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace the @colors/colors specifically style with standard bold.

@webdiscus webdiscus mentioned this pull request Feb 9, 2025
@webdiscus
Copy link
Author

Ansis works on Node.js since 14.0.
Do we need to support legacy versions of Node.js 10.x and 12.x?
If yes, then no problem, I can add support for 10.x and 12.x to Ansis as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant