@@ -63,11 +63,19 @@ def _truncate_middle(value: str, head: int, tail: int) -> str:
6363 return f"{ value [:head ]} \u2026 { value [- tail :]} "
6464
6565
66- def _prov_badge_html (label : str , value : str , color : str ) -> str :
66+ def _prov_badge_html (label : str | None , value : str , color : str ) -> str :
67+ classes = ["prov-badge" , f"prov-badge--{ color } " ]
68+ if label is None :
69+ classes .append ("prov-badge--inline" )
70+ label_html = (
71+ f'<span class="prov-badge-lbl">{ _escape_html (label )} </span>'
72+ if label is not None
73+ else ""
74+ )
6775 return (
68- f'<span class="prov-badge prov-badge-- { color } ">'
76+ f'<span class="{ " " . join ( classes ) } ">'
6977 f'<span class="prov-badge-val">{ _escape_html (value )} </span>'
70- f'<span class="prov-badge-lbl"> { _escape_html ( label ) } </span>'
78+ f" { label_html } "
7179 "</span>"
7280 )
7381
@@ -365,45 +373,34 @@ def render_meta_panel(ctx: ReportContext) -> str:
365373 _STATUS_LABELS = frozenset (
366374 {"Baseline status" , "Metrics baseline status" , "Cache status" }
367375 )
376+ _prov_badge = _prov_badge_html
368377
369378 runtime_python_tag = str (python_tag_value or "" ).strip ()
370379
371380 def _val_html (label : str , value : object ) -> str :
372381 if label in _BOOL_LABELS and isinstance (value , bool ):
373382 true_text , false_text = _BOOL_LABELS [label ]
374- if value :
375- return (
376- '<span class="meta-bool meta-bool-true">'
377- f'<span class="meta-bool-icon">\u2713 </span>'
378- f'<span class="meta-bool-text">{ true_text } </span>'
379- "</span>"
380- )
381- return (
382- '<span class="meta-bool meta-bool-false">'
383- f'<span class="meta-bool-icon">\u2717 </span>'
384- f'<span class="meta-bool-text">{ false_text } </span>'
385- "</span>"
383+ return _prov_badge (
384+ None ,
385+ true_text if value else false_text ,
386+ "green" if value else "red" ,
386387 )
387388 if label in _STATUS_LABELS and isinstance (value , str ) and value .strip ():
388389 raw = value .strip ()
389390 key = raw .lower ()
390391 if key == "ok" :
391- tone = "ok "
392+ color = "green "
392393 text = "ok"
393394 elif key in {"error" , "failed" , "fail" }:
394- tone = "err "
395+ color = "red "
395396 text = raw
396397 elif key in {"missing" , "absent" , "none" }:
397- tone = "warn "
398+ color = "amber "
398399 text = raw
399400 else :
400- tone = "neutral"
401+ color = "neutral"
401402 text = raw
402- return (
403- f'<span class="meta-status meta-status--{ tone } ">'
404- f'<span class="meta-status-dot"></span>'
405- f"{ _escape_html (text )} </span>"
406- )
403+ return _prov_badge (None , text , color )
407404 # Long path/hash values: middle-truncate with copy button + full title
408405 if (
409406 isinstance (value , str )
@@ -437,18 +434,9 @@ def _val_html(label: str, value: object) -> str:
437434 ):
438435 text = _escape_html (value )
439436 if value .strip () == runtime_python_tag :
440- badge = (
441- '<span class="prov-match prov-match--ok" '
442- 'title="Matches runtime Python tag">'
443- "\u2713 matches runtime</span>"
444- )
437+ badge = _prov_badge (None , "matches runtime" , "green" )
445438 else :
446- badge = (
447- '<span class="prov-match prov-match--mismatch" '
448- f'title="Runtime is { runtime_python_tag } ">'
449- f"\u26a0 differs from runtime ({ _escape_html (runtime_python_tag )} )"
450- "</span>"
451- )
439+ badge = _prov_badge (None , f"runtime { runtime_python_tag } " , "amber" )
452440 return f"{ text } { badge } "
453441 return _escape_html (_meta_display (value ))
454442
@@ -505,8 +493,6 @@ def _section_html(title: str, rows: list[tuple[str, object]]) -> str:
505493 _section_html (st , rows ) for st , rows in meta_sections if rows
506494 )
507495
508- _prov_badge = _prov_badge_html
509-
510496 badges : list [str ] = []
511497 if _bl_verified is True :
512498 badges .append (_prov_badge ("Baseline" , "verified" , "green" ))
0 commit comments