aboutsummaryrefslogtreecommitdiff
path: root/scripts/theme-studio/test-app-core.mjs
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-07-02 23:50:27 -0400
committerCraig Jennings <c@cjennings.net>2026-07-02 23:50:27 -0400
commit0ffd6f5a450e716e7ef3297d4bec2fda36649cdf (patch)
treebe3eea222da7603fd14a0830488388eaa9198b48 /scripts/theme-studio/test-app-core.mjs
parent3581c7d1c05eb514aa5462b1142605541fb64d9e (diff)
downloaddotemacs-0ffd6f5a450e716e7ef3297d4bec2fda36649cdf.tar.gz
dotemacs-0ffd6f5a450e716e7ef3297d4bec2fda36649cdf.zip
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.
Diffstat (limited to 'scripts/theme-studio/test-app-core.mjs')
-rw-r--r--scripts/theme-studio/test-app-core.mjs26
1 files changed, 25 insertions, 1 deletions
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);