Skip to content

feat: Label(compact=True) for tight spacing without a shared CSS change - #131

Merged
petercorke merged 1 commit into
jhavl:futurefrom
petercorke:feat/label-compact
Aug 21, 2026
Merged

feat: Label(compact=True) for tight spacing without a shared CSS change#131
petercorke merged 1 commit into
jhavl:futurefrom
petercorke:feat/label-compact

Conversation

@petercorke

Copy link
Copy Markdown
Collaborator

Summary

.label-div's default margin (1cm top, 0.5cm bottom) and font-size (1.3em, bold) are sized for an occasional standalone heading, not several Labels stacked close together -- e.g. a multi-line live readout next to a slider panel, where the current spacing looks disproportionately spacious and pushes other elements off-screen (found while building a Swift teach() panel for roboticstoolbox-python -- see companion RTB PR).

No existing example in this repo uses Label at all, so nothing currently depends on today's spacing -- but editing the shared .label-div CSS class directly would still silently change the look for any future/external caller that does want the current spacious heading style.

Fix

Label(desc='', compact=False) -- compact=True applies a tighter margin/font-size as an inline style override in the JS constructor. Default False leaves the shared CSS class, and every other Label instance, completely untouched.

Test plan

  • tests/test_swift_element.py: new test_label_compact_to_dict, existing test_label_to_dict updated for the new compact field
  • Full suite passes: 94 passed, 9 deselected (one pre-existing, unrelated spatialgeometry Polyline gap from a stale local install, not this change)
  • Manually verified in a real browser: 6 stacked compact Labels no longer push joint sliders off-screen

.label-div's default margin (1cm top, 0.5cm bottom) and font-size
(1.3em, bold) are sized for an occasional standalone heading, not
several Labels stacked close together -- e.g. a multi-line live
readout next to a slider panel, where the current spacing looks
disproportionately spacious and pushes other elements off-screen.

No existing example uses Label at all, so nothing currently depends on
today's spacing -- but editing the shared .label-div CSS class directly
would still silently change the look for any future/external caller
that does want the current spacious heading style. compact=True is
opt-in per-instance instead: applied as an inline style override in
the JS constructor, default False leaves the shared class and every
other Label untouched.
@petercorke
petercorke merged commit 1ee8309 into jhavl:future Aug 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant