Rename Look attribute color to bordercolor
This commit is contained in:
parent
bb39a12256
commit
8e09cb9841
@ -36,7 +36,7 @@ class Metadata(dict):
|
|||||||
@dataclass
|
@dataclass
|
||||||
class Look:
|
class Look:
|
||||||
"""Colors and font that defines how an element should look like."""
|
"""Colors and font that defines how an element should look like."""
|
||||||
color: Optional[Color] = None
|
bordercolor: Optional[Color] = None
|
||||||
bgcolor: Optional[Color] = None
|
bgcolor: Optional[Color] = None
|
||||||
fontcolor: Optional[Color] = None
|
fontcolor: Optional[Color] = None
|
||||||
fontname: Optional[PlainText] = None
|
fontname: Optional[PlainText] = None
|
||||||
@ -51,17 +51,17 @@ class Look:
|
|||||||
|
|
||||||
def graph_args(self) -> dict:
|
def graph_args(self) -> dict:
|
||||||
"""Return dict with arguments to a dot graph."""
|
"""Return dict with arguments to a dot graph."""
|
||||||
return {k:v for k,v in self._2dict().items() if k != 'color'}
|
return {k:v for k,v in self._2dict().items() if k != 'bordercolor'}
|
||||||
|
|
||||||
def node_args(self) -> dict:
|
def node_args(self) -> dict:
|
||||||
"""Return dict with arguments to a dot node with filled style."""
|
"""Return dict with arguments to a dot node with filled style."""
|
||||||
return {k.replace('bg', 'fill'):v for k,v in self._2dict().items()}
|
return {k.replace('border', '').replace('bg', 'fill'):v for k,v in self._2dict().items()}
|
||||||
|
|
||||||
def html_style(self, color_prefix: Optional[str] = None, include_all: bool = True) -> str:
|
def html_style(self, color_prefix: Optional[str] = None, include_all: bool = True) -> str:
|
||||||
"""Return HTML style value containing all non-empty option values."""
|
"""Return HTML style value containing all non-empty option values."""
|
||||||
translated = Look(**self._2dict())
|
translated = Look(**self._2dict())
|
||||||
return ' '.join(value for value in (
|
return ' '.join(value for value in (
|
||||||
f'{color_prefix} {translated.color};' if self.color and color_prefix else None,
|
f'{color_prefix} {translated.bordercolor};' if self.bordercolor and color_prefix else None,
|
||||||
f'background-color: {translated.bgcolor};' if self.bgcolor and include_all else None,
|
f'background-color: {translated.bgcolor};' if self.bgcolor and include_all else None,
|
||||||
f'color: {translated.fontcolor};' if self.fontcolor and include_all else None,
|
f'color: {translated.fontcolor};' if self.fontcolor and include_all else None,
|
||||||
f'font-family: {self.fontname};' if self.fontname and include_all else None,
|
f'font-family: {self.fontname};' if self.fontname and include_all else None,
|
||||||
@ -69,7 +69,7 @@ class Look:
|
|||||||
) if value)
|
) if value)
|
||||||
|
|
||||||
DEFAULT_LOOK = Look(
|
DEFAULT_LOOK = Look(
|
||||||
color = 'BK',
|
bordercolor = 'BK',
|
||||||
bgcolor = 'WH',
|
bgcolor = 'WH',
|
||||||
fontcolor = 'BK',
|
fontcolor = 'BK',
|
||||||
fontname = 'arial',
|
fontname = 'arial',
|
||||||
|
|||||||
@ -106,7 +106,7 @@ class Harness:
|
|||||||
dot.attr('edge', style='bold',
|
dot.attr('edge', style='bold',
|
||||||
**self.options.base.node_args())
|
**self.options.base.node_args())
|
||||||
|
|
||||||
wire_border_hex = wv_colors.get_color_hex(self.options.base.color)[0]
|
wire_border_hex = wv_colors.get_color_hex(self.options.base.bordercolor)[0]
|
||||||
|
|
||||||
# prepare ports on connectors depending on which side they will connect
|
# prepare ports on connectors depending on which side they will connect
|
||||||
for _, cable in self.cables.items():
|
for _, cable in self.cables.items():
|
||||||
|
|||||||
@ -40,7 +40,7 @@ def nested_html_table(rows: List[Union[GvHtml, List[Optional[GvHtmlX]], None]],
|
|||||||
def table_attr(look: Optional[Look]) -> GvHtmlAttr:
|
def table_attr(look: Optional[Look]) -> GvHtmlAttr:
|
||||||
"""Return table tag attributes containing all non-empty table option values."""
|
"""Return table tag attributes containing all non-empty table option values."""
|
||||||
return '' if not look else ''.join({
|
return '' if not look else ''.join({
|
||||||
f' {k}="{v}"' for k,v in look._2dict().items() if v and 'font' not in k})
|
f' {k.replace("border", "")}="{v}"' for k,v in look._2dict().items() if v and 'font' not in k})
|
||||||
|
|
||||||
def font_attr(look: Optional[Look]) -> GvHtmlAttr:
|
def font_attr(look: Optional[Look]) -> GvHtmlAttr:
|
||||||
"""Return font tag attributes containing all non-empty font option values."""
|
"""Return font tag attributes containing all non-empty font option values."""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user