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

fix: Fix color resetting for borders #428

Merged
merged 2 commits into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/internalTable/internal-table-printer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const renderOneLine = (
colorMap: ColorMap
): string => {
const line = new ColoredConsoleLine(colorMap);
line.addCharsWithColor(DEFAULT_ROW_FONT_COLOR, tableStyle.vertical);
line.addCharsWithColor('', tableStyle.vertical); // dont Color the Column borders
columns.forEach((column) => {
const thisLineHasText =
currentLineIndex < widthLimitedColumnsArray[column.name].length;
Expand All @@ -48,7 +48,7 @@ const renderOneLine = (
column.length || DEFAULT_COLUMN_LEN
)
);
line.addCharsWithColor(DEFAULT_ROW_FONT_COLOR, ` ${tableStyle.vertical}`);
line.addCharsWithColor('', ` ${tableStyle.vertical}`); // dont Color the Column borders
});
return line.renderConsole();
};
Expand Down
16 changes: 8 additions & 8 deletions test/__snapshots__/alignment.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

exports[`Testing column alignment all kind of alignments are working 1`] = `
"┌──────────────────────┬──────────────────────────────────────────┬────────────────────┐
│ red_left_align_index │  right_align_text │ green_value_center │
│ red_left_align_index │  right_align_text │ green_value_center
├──────────────────────┼──────────────────────────────────────────┼────────────────────┤
│ 2  │  This row is blue │  10.212  │
│ 3  │  I would like some red wine please │  10.212  │
│ 4  │  I would like some cyan wine please │  10.212  │
│ 5  │ I would like some white_bold wine please │  10.212  │
│ 6  │  I would like some crimson sky please │  10.212  │
│ 7  │  I would like some green gemuse please │  20  │
│ 8  │  I would like some gelb bananen bitte │  100  │
│ 2  │  This row is blue │  10.212 
│ 3  │  I would like some red wine please │  10.212 
│ 4  │  I would like some cyan wine please │  10.212 
│ 5  │ I would like some white_bold wine please │  10.212 
│ 6  │  I would like some crimson sky please │  10.212 
│ 7  │  I would like some green gemuse please │  20 
│ 8  │  I would like some gelb bananen bitte │  100 
└──────────────────────┴──────────────────────────────────────────┴────────────────────┘"
`;
10 changes: 5 additions & 5 deletions test/__snapshots__/cellColor.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

exports[`Example: Print a simple Table with cell colors cell colors are working 1`] = `
"┌───────┬─────────┬────────┐
│ index │  text │  value │
│ index │  text │  value
├───────┼─────────┼────────┤
│  1 │  red │ 10.212 │
│  2 │  green │  20 │
│  3 │  yellow │  100 │
│  4 │ magenta │  300 │
│  1 │  red │ 10.212
│  2 │  green │  20
│  3 │  yellow │  100
│  4 │ magenta │  300
└───────┴─────────┴────────┘"
`;
16 changes: 8 additions & 8 deletions test/__snapshots__/columnColor.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

exports[`Example: Print a simple Table with column colors column colors are working 1`] = `
"┌──────────────────────┬──────────────────────────────────────────┬─────────────┐
│ red_left_align_index │  right_align_text │ green_value │
│ red_left_align_index │  right_align_text │ green_value
├──────────────────────┼──────────────────────────────────────────┼─────────────┤
│ 2  │  This row is blue │  10.212 │
│ 3  │  I would like some red wine please │  10.212 │
│ 4  │  I would like some cyan wine please │  10.212 │
│ 5  │ I would like some white_bold wine please │  10.212 │
│ 6  │  I would like some crimson sky please │  10.212 │
│ 7  │  I would like some green gemuse please │  20 │
│ 8  │  I would like some gelb bananen bitte │  100 │
│ 2  │  This row is blue │  10.212
│ 3  │  I would like some red wine please │  10.212
│ 4  │  I would like some cyan wine please │  10.212
│ 5  │ I would like some white_bold wine please │  10.212
│ 6  │  I would like some crimson sky please │  10.212
│ 7  │  I would like some green gemuse please │  20
│ 8  │  I would like some gelb bananen bitte │  100
└──────────────────────┴──────────────────────────────────────────┴─────────────┘"
`;
16 changes: 8 additions & 8 deletions test/__snapshots__/computedColumns.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

exports[`Example: Print a simple Table with Computed Columns Computed Columns are working 1`] = `
"┌────────────┬─────────────┬─────┬─────────────┬──────────────┬─────┬─────────────┬──────────────┐
│ red_amount │ blue_amount │ sum │ red_percent │ blue_percent │ sum │ red_percent │ blue_percent │
│ red_amount │ blue_amount │ sum │ red_percent │ blue_percent │ sum │ red_percent │ blue_percent
├────────────┼─────────────┼─────┼─────────────┼──────────────┼─────┼─────────────┼──────────────┤
│  2 │  3 │  5 │  40.00 │  60.00 │  5 │  40.00 │  60.00 │
│  1 │  1 │  2 │  50.00 │  50.00 │  2 │  50.00 │  50.00 │
│  5 │  6 │  11 │  45.45 │  54.55 │  11 │  45.45 │  54.55 │
│  2 │  3 │  5 │  40.00 │  60.00 │  5 │  40.00 │  60.00
│  1 │  1 │  2 │  50.00 │  50.00 │  2 │  50.00 │  50.00
│  5 │  6 │  11 │  45.45 │  54.55 │  11 │  45.45 │  54.55
└────────────┴─────────────┴─────┴─────────────┴──────────────┴─────┴─────────────┴──────────────┘"
`;

exports[`Example: Print a simple Table with Computed Columns Computed Columns are working with Title 1`] = `
"┌────────────┬─────────────┬─────┬─────────────┬──────────────┬─────┬─────────────┬──────────────┐
│ red_amount │ blue_amount │ sum │ Red Percent │ Blue Percent │ sum │ Red Percent │ Blue Percent │
│ red_amount │ blue_amount │ sum │ Red Percent │ Blue Percent │ sum │ Red Percent │ Blue Percent
├────────────┼─────────────┼─────┼─────────────┼──────────────┼─────┼─────────────┼──────────────┤
│  2 │  3 │  5 │  40.00 │  60.00 │  5 │  40.00 │  60.00 │
│  1 │  1 │  2 │  50.00 │  50.00 │  2 │  50.00 │  50.00 │
│  5 │  6 │  11 │  45.45 │  54.55 │  11 │  45.45 │  54.55 │
│  2 │  3 │  5 │  40.00 │  60.00 │  5 │  40.00 │  60.00
│  1 │  1 │  2 │  50.00 │  50.00 │  2 │  50.00 │  50.00
│  5 │  6 │  11 │  45.45 │  54.55 │  11 │  45.45 │  54.55
└────────────┴─────────────┴─────┴─────────────┴──────────────┴─────┴─────────────┴──────────────┘"
`;
8 changes: 4 additions & 4 deletions test/__snapshots__/customizedColor.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

exports[`Example: Print a simple Table with Custom column colors Custom column colors are working 1`] = `
"┌──────────────────────┬──────────────────────────┬─────────────┐
│ red_left_align_index │  right_align_text │ green_value │
│ red_left_align_index │  right_align_text │ green_value
├──────────────────────┼──────────────────────────┼─────────────┤
│ 2  │ This is my defined Green │  10.212 │
│ 3  │ This row is blue as well │  10.212 │
│ 4  │  This row is green │  10.212 │
│ 2  │ This is my defined Green │  10.212
│ 3  │ This row is blue as well │  10.212
│ 4  │  This row is green │  10.212
└──────────────────────┴──────────────────────────┴─────────────┘"
`;