feat(ui): standardize inspector spacing and compact level geometry

This commit is contained in:
Codex
2026-11-04 18:18:10 +03:00
parent 8ff33a6a17
commit be929f9d8e
10 changed files with 74 additions and 9 deletions
+16
View File
@@ -47,3 +47,19 @@ test("viewport controls share one scale without scaling nested controls twice",
assert.match(styles, /\.nodedc-segmented\) :is\([^}]+zoom: 1;/);
assert.ok(JSON.parse(registrySource).components.find(c=>c.id==='button').domContract.includes('nodedc-viewport-controls'));
});
import { LevelButton } from "../packages/ui-react/dist/index.js";
import { levelButtonGeometry } from "../packages/ui-react/dist/levelButtonGeometry.js";
test("compact level indicators fit both contrast layers with proportional text and padding", () => {
const tiny=levelButtonGeometry({width:32,height:12,radius:4},4);
const normal=levelButtonGeometry({width:64,height:24,radius:8},4);
assert.equal(tiny.fontSize,'calc(var(--nodedc-font-size-md) * 0.5)');
assert.equal(tiny.padding,'calc(0.25rem * 0.5) calc(var(--nodedc-space-2) * 0.5)');
assert.equal(normal.fontSize,'calc(var(--nodedc-font-size-md) * 1)');
assert.equal(levelButtonGeometry({width:-1,height:NaN},4).width,32);
assert.equal(levelButtonGeometry({width:-1,height:NaN},4).height,46);
const markup=renderToStaticMarkup(createElement(LevelButton,{value:1,label:'Battery',fillColor:'#ffffff',geometry:{width:32,height:12,radius:4}}));
assert.match(markup,/width:32px/);assert.match(markup,/height:12px/);
assert.match(markup,/nodedc-level-button__fill/);
assert.match(markup,/100/);assert.match(markup,/aria-label="Battery: 100%"/);
});