Skip to content

Commit 619285a

Browse files
authored
Better colors in logging query results when using dark mode (#238)
1 parent ff1645d commit 619285a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/DatabaseLibrary/query.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -803,12 +803,13 @@ def _log_query_results(self, col_names, result_rows, log_head: Optional[int] = N
803803
log_head = self.LOG_QUERY_RESULTS_HEAD
804804
cell_border_and_align = "border: 1px solid rgb(160 160 160);padding: 8px 10px;text-align: center;"
805805
table_border = "2px solid rgb(140 140 140)"
806-
row_index_color = "#d6ecd4"
807-
msg = f'<div style="max-width: 100%; overflow-x: auto;">'
806+
row_index_background_color = "#d6ecd4"
807+
row_index_text_color = "black"
808+
msg = '<div style="max-width: 100%; overflow-x: auto;">'
808809
msg += f'<table style="width: auto; border-collapse: collapse; border: {table_border}">'
809810
msg += f'<caption style="text-align: left; font-weight: bold; padding: 5px;">Query returned {len(result_rows)} rows</caption>'
810811
msg += "<tr>"
811-
msg += f'<th scope="col" style="background-color: {row_index_color}; {cell_border_and_align}">Row</th>'
812+
msg += f'<th scope="col" style="color:{row_index_text_color}; background-color: {row_index_background_color}; {cell_border_and_align}">Row</th>'
812813
for col in col_names:
813814
msg += f'<th scope="col" style="background-color: #505050; color: #fff;{cell_border_and_align}">{col}</th>'
814815
msg += "</tr>"
@@ -819,9 +820,9 @@ def _log_query_results(self, col_names, result_rows, log_head: Optional[int] = N
819820
break
820821
row_style = ""
821822
if i % 2 == 0:
822-
row_style = ' style="background-color: #eee;"'
823+
row_style = ' style="background-color: var(--secondary-color, #eee)"'
823824
msg += f"<tr{row_style}>"
824-
msg += f'<th scope="row" style="background-color: {row_index_color};{cell_border_and_align}">{i}</th>'
825+
msg += f'<th scope="row" style="color:{row_index_text_color}; background-color: {row_index_background_color};{cell_border_and_align}">{i}</th>'
825826
for cell in row:
826827
msg += f'<td style="{cell_border_and_align}">{cell}</td>'
827828
msg += "</tr>"

0 commit comments

Comments
 (0)