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

🚀 Feature: add color #176

Open
2 tasks done
whyboris opened this issue Nov 10, 2024 · 6 comments
Open
2 tasks done

🚀 Feature: add color #176

whyboris opened this issue Nov 10, 2024 · 6 comments
Labels
status: accepting prs Please, send a pull request to resolve this! 🙏 type: feature New enhancement or request 🚀

Comments

@whyboris
Copy link

Bug Report Checklist

Overview

Compared to console.table(myTable); the output of this library does not colorize the column entries

Additional Info

It would be lovely to match the colors of console.table (feel free to change colors however you'd like).

Feels like it may be somewhat straight-forward with:

if (typeof entry === string) {
 return green(entry);
}

function green(text) {
  console.log('\x1b[32m' + text + '\x1b[0m')
}

ps - It would be maybe nice not to include the ' around strings 🤷‍♂️

@whyboris whyboris added the type: feature New enhancement or request 🚀 label Nov 10, 2024
@JoshuaKGoldberg
Copy link
Owner

Huh, does the Node.js console.table colorize entries for you? It's plain colored on my system, including shells that have color support. Could you post a screenshot please?

A hunch: are you maybe thinking of the browser console table? That would be out of scope for this lib, which is just Node.js-focused.

@JoshuaKGoldberg JoshuaKGoldberg added the status: waiting for author Needs an action taken by the original poster label Nov 12, 2024
@whyboris
Copy link
Author

whyboris commented Nov 15, 2024

I am using Alacritty with Git Bash (comes when you install Git) as the shell on Windows 10 🤷‍♂️

I am doing console.table on an array of strings and floats that come from a JSON

[{"amount":5.0,"date":"2024-10-22","email":"the###@###.com"}]

screenshot of console.table colorizing output

blue rectangles over text to obscure email address 🕵️‍♀️

Copy link

Uh oh! @whyboris, the image you shared is missing helpful alt text. Check #176 (comment).

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

@JoshuaKGoldberg JoshuaKGoldberg removed the status: waiting for author Needs an action taken by the original poster label Dec 1, 2024
@JoshuaKGoldberg
Copy link
Owner

JoshuaKGoldberg commented Dec 1, 2024

Ah, you're right! This also happens on my stock macOS VS Code:

import { table } from "console-table-without-index";

const data = [{ "amount": 5.0, "date": "2024-10-22", "email": "the###@###.com" }]

console.table(data);

console.log(table(data));
Screenshot of the output from the code. The first table has yellow 5 and green strings in cells; the latter does not.

This'll have to use a package like supports-color to determine whether the terminal supports color. Accepting PRs!

@JoshuaKGoldberg JoshuaKGoldberg added the status: accepting prs Please, send a pull request to resolve this! 🙏 label Dec 1, 2024
@JoshuaKGoldberg
Copy link
Owner

@all-contributors please add @whyboris for ideas.

🤖 Beep boop! This comment was added automatically by all-contributors-auto-action.
Not all contributions can be detected from Git & GitHub alone. Please comment any missing contribution types this bot missed.
...and of course, thank you for contributing! 💙

Copy link
Contributor

@JoshuaKGoldberg

I've put up a pull request to add @whyboris! 🎉

JoshuaKGoldberg pushed a commit that referenced this issue Dec 3, 2024
Adds @whyboris as a contributor for ideas.

This was requested by JoshuaKGoldberg [in this
comment](#176 (comment))

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepting prs Please, send a pull request to resolve this! 🙏 type: feature New enhancement or request 🚀
Projects
None yet
Development

No branches or pull requests

2 participants