diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index e701425..a29ce35 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -8,7 +8,7 @@ from wireviz.wv_colors import get_color_hex from wireviz.wv_helper import awg_equiv, mm2_equiv, tuplelist2tsv, \ nested_html_table, flatten2d, index_if_list, html_line_breaks, \ graphviz_line_breaks, remove_line_breaks, open_file_read, open_file_write, \ - html_image, html_caption, manufacturer_info_field + html_colorbar, html_image, html_caption, manufacturer_info_field from collections import Counter from typing import List from pathlib import Path @@ -96,17 +96,13 @@ class Harness: [html_line_breaks(connector.type), html_line_breaks(connector.subtype), f'{connector.pincount}-pin' if connector.show_pincount else None, - connector.color, '' if connector.color else None], + connector.color, html_colorbar(connector.color)], '' if connector.style != 'simple' else None, [html_image(connector.image)], [html_caption(connector.image)], [html_line_breaks(connector.notes)]] html.extend(nested_html_table(rows)) - if connector.color: # add color bar next to color info, if present - colorbar = f' bgcolor="{wv_colors.translate_color(connector.color, "HEX")}" width="4">' # leave out ' tag - html = [row.replace('>', colorbar) for row in html] - if connector.style != 'simple': pinhtml = [] pinhtml.append('') @@ -173,17 +169,13 @@ class Harness: f'{cable.gauge} {cable.gauge_unit}{awg_fmt}' if cable.gauge else None, '+ S' if cable.shield else None, f'{cable.length} m' if cable.length > 0 else None, - cable.color, '' if cable.color else None], + cable.color, html_colorbar(cable.color)], '', [html_image(cable.image)], [html_caption(cable.image)], [html_line_breaks(cable.notes)]] html.extend(nested_html_table(rows)) - if cable.color: # add color bar next to color info, if present - colorbar = f' bgcolor="{wv_colors.translate_color(cable.color, "HEX")}" width="4">' # leave out ' tag - html = [row.replace('>', colorbar) for row in html] - wirehtml = [] wirehtml.append('
') # conductor table wirehtml.append(' ') diff --git a/src/wireviz/wv_helper.py b/src/wireviz/wv_helper.py index 32b8fb6..8385f7e 100644 --- a/src/wireviz/wv_helper.py +++ b/src/wireviz/wv_helper.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +from wireviz import wv_colors from typing import List awg_equiv_table = { @@ -55,6 +56,9 @@ def nested_html_table(rows): html.append('
 
') return html +def html_colorbar(color): + return f'' if color else None + def html_image(image): if not image: return None