From 0ffd6f5a450e716e7ef3297d4bec2fda36649cdf Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Thu, 2 Jul 2026 23:50:27 -0400 Subject: feat(theme-studio): previews render the chosen face height heightCssValue maps a face's height to CSS from its stored kind: a relative multiplier renders as em, an absolute 1/10pt value as true pt, with legacy objects falling back to integer/fractional inference. uiCss feeds it to the mock editor, so the mode-line, mode-line-inactive, and line-number bars visibly thicken with an absolute height while the buffer text stays put; paintUI scales the UI row's sample text; the package-preview span builder swaps its em-only sizing for the same kind-aware value. faceCss now accepts a unit-carrying string for fontSize alongside the existing em number. --- scripts/theme-studio/test-app-core.mjs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'scripts/theme-studio/test-app-core.mjs') diff --git a/scripts/theme-studio/test-app-core.mjs b/scripts/theme-studio/test-app-core.mjs index 29c43abd..195846e7 100644 --- a/scripts/theme-studio/test-app-core.mjs +++ b/scripts/theme-studio/test-app-core.mjs @@ -11,7 +11,7 @@ import { clearPalettePlan, deletePaletteColumnPlan, groundColumnMembersFromPalette, areAllLocked, lockToggleLabel, toggleLockSet, galleryModel, appViewKeysSorted, faceBoxNonDefaults, overflowNonDefault, stepViewIndex, cssWeight, faceDecoration, boxCss, faceCss, composeHoverTitle, - clampHeight, HEIGHT_MIN, HEIGHT_MAX, heightControlKind, parseHeightEntry, ptHint, + clampHeight, HEIGHT_MIN, HEIGHT_MAX, heightControlKind, parseHeightEntry, ptHint, heightCssValue, } from './app-core.js'; import { planPaletteGenerator, entriesForGeneratedColumn } from './palette-generator-core.js'; import { oklch2hex, deltaE } from './colormath.js'; @@ -1098,6 +1098,30 @@ test('ptHint: Boundary — no number, no hint', () => { assert.equal(ptHint(null), ''); assert.equal(ptHint(undefined), ''); }); + +test('heightCssValue: Normal — relative renders as em, absolute as true pt', () => { + assert.equal(heightCssValue({ height: 1.3, heightMode: 'rel' }), '1.3em'); + assert.equal(heightCssValue({ height: 130, heightMode: 'abs' }), '13pt'); + // the integral-float case: the stored kind rules, not the number type + assert.equal(heightCssValue({ height: 2, heightMode: 'rel' }), '2em'); +}); + +test('heightCssValue: Normal — a legacy object without a kind infers from the number', () => { + assert.equal(heightCssValue({ height: 1.4 }), '1.4em'); + assert.equal(heightCssValue({ height: 130 }), '13pt'); +}); + +test('heightCssValue: Boundary — unset, identity, or non-number yields null', () => { + assert.equal(heightCssValue({ height: null }), null); + assert.equal(heightCssValue({ height: 1 }), null); + assert.equal(heightCssValue({}), null); + assert.equal(heightCssValue(null), null); +}); + +test('faceCss: Normal — a string fontSize lands verbatim, a number stays em', () => { + assert.ok(faceCss({}, '#111', null, { fontSize: '13pt' }).includes('font-size:13pt')); + assert.ok(faceCss({}, '#111', null, { fontSize: 1.15 }).includes('font-size:1.15em')); +}); test('faceBoxNonDefaults: inherit and box differences are flagged', () => { assert.equal(faceBoxNonDefaults({ inherit: 'bold' }, { inherit: null }).inherit, true); assert.equal(faceBoxNonDefaults({ box: { style: 'line' } }, { box: null }).box, true); -- cgit v1.2.3