fix(rack): centre 0U rail labels across the bar (dominant-baseline)
All checks were successful
Build docs site / build (push) Successful in 52s
Build slides / build (push) Successful in 1m11s

This commit is contained in:
sjat 2026-06-24 19:07:10 +02:00
parent e1c05a6c88
commit a6033e2038
4 changed files with 14 additions and 5 deletions

View file

@ -220,12 +220,12 @@
<a href="/hardware/pdu01/">
<title>pdu01 · pdu · in-use · cluster: — · 0U left</title>
<rect x="12" y="40" width="16" height="960" fill="#e15759" stroke="#333333" stroke-width="1.5"/>
<text x="20" y="520" text-anchor="middle" fill="#ffffff" transform="rotate(-90 20 520)">pdu01</text>
<text x="20" y="520" text-anchor="middle" dominant-baseline="central" fill="#ffffff" transform="rotate(-90 20 520)">pdu01</text>
</a>
<a href="/hardware/pdu02/">
<title>pdu02 · pdu · in-use · cluster: — · 0U right</title>
<rect x="618" y="40" width="16" height="960" fill="#e15759" stroke="#333333" stroke-width="1.5"/>
<text x="626" y="520" text-anchor="middle" fill="#ffffff" transform="rotate(-90 626 520)">pdu02</text>
<text x="626" y="520" text-anchor="middle" dominant-baseline="central" fill="#ffffff" transform="rotate(-90 626 520)">pdu02</text>
</a>
<a href="/hardware/srv01/">
<title>srv01 · server · staging · cluster: tappaas · shf01/front/slot 1</title>

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View file

@ -227,12 +227,12 @@ _Auto-generated from `docs/hardware/*.md` (items with `rack: rack01`) — do not
<a href="/hardware/pdu01/">
<title>pdu01 · pdu · in-use · cluster: — · 0U left</title>
<rect x="12" y="40" width="16" height="960" fill="#e15759" stroke="#333333" stroke-width="1.5"/>
<text x="20" y="520" text-anchor="middle" fill="#ffffff" transform="rotate(-90 20 520)">pdu01</text>
<text x="20" y="520" text-anchor="middle" dominant-baseline="central" fill="#ffffff" transform="rotate(-90 20 520)">pdu01</text>
</a>
<a href="/hardware/pdu02/">
<title>pdu02 · pdu · in-use · cluster: — · 0U right</title>
<rect x="618" y="40" width="16" height="960" fill="#e15759" stroke="#333333" stroke-width="1.5"/>
<text x="626" y="520" text-anchor="middle" fill="#ffffff" transform="rotate(-90 626 520)">pdu02</text>
<text x="626" y="520" text-anchor="middle" dominant-baseline="central" fill="#ffffff" transform="rotate(-90 626 520)">pdu02</text>
</a>
<a href="/hardware/srv01/">
<title>srv01 · server · staging · cluster: tappaas · shf01/front/slot 1</title>

View file

@ -462,7 +462,8 @@ def render_svg(rack: str, items: list[dict]) -> str:
f"fill=\"{color}\" {_stroke_attrs(fm.get('status'))}/>"
)
p.append(
f'<text x="{cx}" y="{cy}" text-anchor="middle" fill="#ffffff" '
f'<text x="{cx}" y="{cy}" text-anchor="middle" '
f'dominant-baseline="central" fill="#ffffff" '
f'transform="rotate(-90 {cx} {cy})">{_esc(name)}</text>'
)
p.append("</a>")

View file

@ -156,6 +156,14 @@ def test_render_svg_draws_zero_u_rail():
assert "rotate(-90" in svg
def test_render_svg_rail_label_is_centered_across_bar():
# The rotated 0U rail label must be centered across the narrow bar width,
# not sitting on the alphabetic baseline (which reads off-centre).
items = [item(hostname="pdu01", kind="pdu", rack_face="left")]
svg = gen_rack.render_svg("rack01", items)
assert 'dominant-baseline="central"' in svg
def test_render_svg_both_face_draws_in_both_columns():
items = [item(hostname="dev", rack_u=10, u_height=1, rack_face="both")]
svg = gen_rack.render_svg("rack01", items)