fix(controls): preserve editable color values and settings typography

This commit is contained in:
Codex
2026-11-04 00:39:39 +03:00
parent cb534dbe39
commit ac65b1167f
4 changed files with 48 additions and 6 deletions
+13
View File
@@ -1,5 +1,6 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import {readFile} from 'node:fs/promises';
import {createElement as h} from 'react';
import {renderToStaticMarkup} from 'react-dom/server';
import {LoadingRegion,Description,SettingsCard,ComparisonTable} from '../packages/ui-react/dist/index.js';
@@ -23,3 +24,15 @@ test('SettingsCard and standalone explanatory paragraphs use one typography comp
assert.match(renderToStaticMarkup(h(Description,null,'help')),/class="nodedc-description"/);
assert.match(renderToStaticMarkup(h(SettingsCard,{title:'Settings',description:'help'})),/<p class="nodedc-description">help/);
});
test('legacy card paragraphs and live descriptions share small muted typography, without targeting controls',async()=>{
const css=await readFile(new URL('../packages/ui-core/styles.css',import.meta.url),'utf8');
const blocks=[...css.matchAll(/([^{}]+)\{([^{}]*)\}/g)].map(([,selectors,body])=>({selectors,body}));
const copy=blocks.find(b=>b.selectors.includes('.nodedc-description')&&b.body.includes('font-size:'));
assert.ok(copy);
assert.match(copy.selectors,/\.nodedc-settings-card__titles p/);
assert.match(copy.selectors,/\.nodedc-settings-card__body :where\(p:not\(\[class\]\)\)/);
for(const declaration of ['font-family: inherit','font-weight: 400','color: var(--nodedc-text-muted)','font-size: var(--nodedc-font-size-sm)','line-height: 1.4'])assert.ok(copy.body.includes(declaration),declaration);
assert.doesNotMatch(copy.selectors,/h[1-6]|button|input|select/);
const markup=renderToStaticMarkup(h(Description,{role:'status','aria-live':'polite'},'Waiting for device'));
assert.match(markup,/role="status"/);assert.match(markup,/aria-live="polite"/);assert.match(markup,/class="nodedc-description"/);
});