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

Add ability to set custom styles per cell (border characters/colors, padding, etc). #4

Closed
gajus opened this issue Sep 15, 2015 · 3 comments

Comments

@gajus
Copy link
Owner

gajus commented Sep 15, 2015

This feature is mentioned in https://github.com/jamestalmage/cli-table2 documentation. Though, there is no documentation or examples of it being in use.

@jamestalmage can you share an example?

I don't understand how some of this be possible given that cells share common borders.

@jamestalmage
Copy link

I'd have to review, but I believe in cli-table2 it's a pretty naive implementation that does a merge of the default config, the table config, the the cell config using merge (listed in order of increasing importance).

The way cli-table works is that each cell is responsible for rendering it's own top and left edges. Only cells in the last column render their right edge. Only cells in the last row render their bottom edge. This does not make for very convenient custom characters at the cell level. If you want to change the bottom / right edge of a particular cell, you actually need to find the neighbor responsible for that and set the value there. It would be better if, when deciding what character to use for it's own left edge, a cell checked first for a custom left character in it's own config, if not, check for a custom right character in the config of it's neighbor, and followed by the left character as configured at the table level, followed by the default.

Corners get even more interesting (who gets to take precedence).

I'm not sure how necessary "custom chars" really are. It might be better just to offer the ability to make certain lines "double" or "heavy".

box-chars

box-chars helps pick the correct character for a given edge or intersection

For a standard top left corner character (a character that points down, and to the right), you find it as follows:

var box = require('box-chars');

var left = box.NOTHING;    // nothing pointing to the left from top-left corner
var right = box.LIGHT;     // other options are HEAVY or DOUBLE
var up = box.NOTHING;      // nothing pointing up
var down = box.LIGHT;

box(left, right, up, down);
//=> ┌

for situations that do not exist (i.e. right=LIGHT, left=DOUBLE), it picks a sensible default (DOUBLE, DOUBLE in that case).

box-chars is not documented, but it is well tested.

@jamestalmage
Copy link

@gajus
Added you as collaborator on box-chars, if you think it's worthwhile for table, run with it. I haven't touched it in a while

@gajus
Copy link
Owner Author

gajus commented Oct 4, 2015

I thought about this and consider this feature to be too much of an edge case. Very few packages will use this feature and it will add a considerable level of complexity to the existing code. As such, it will not be implemented.

@gajus gajus closed this as completed Oct 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants