From 10a567898783ba300841922fcc1d469408efb0c5 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 20 Jun 2026 16:28:10 -0400 Subject: refactor(theme-studio): drop the orphaned dropdownRowTextColor helper dropdownRowTextColor was exported and unit-tested but had no runtime caller: it computed text color for a vertical-list dropdown row, a UI replaced by the swatch gallery popup (colored buttons, no per-row text), so its regression rationale is moot. Remove the function, its export, and its four tests; regenerate the page (theme-studio.html staged so check-generated stays green). --- scripts/theme-studio/app-core.js | 13 +------------ scripts/theme-studio/test-app-core.mjs | 19 +------------------ scripts/theme-studio/theme-studio.html | 11 ----------- 3 files changed, 2 insertions(+), 41 deletions(-) (limited to 'scripts/theme-studio') diff --git a/scripts/theme-studio/app-core.js b/scripts/theme-studio/app-core.js index a69d958c0..f02191c67 100644 --- a/scripts/theme-studio/app-core.js +++ b/scripts/theme-studio/app-core.js @@ -156,17 +156,6 @@ function resolveUiAttr(face,attr,uimap){ return walkInheritChain(face,f=>UI_INHERIT[f],f=>uimap[f]&&uimap[f][attr]); } -// Text color for a swatch-dropdown popup row. A row showing a real palette color -// sits on the popup's own fixed background, so its name/hex text must inherit the -// popup foreground (return '' to use the CSS color). Coloring it for contrast -// against the swatch instead picks near-black text for a mid/dark swatch, which -// is unreadable on the dark popup. Only the "default" row, filled solid with -// SHOWN, uses a contrast color computed against that fill. -function dropdownRowTextColor(hex,shown,textOnFn){ - if(hex)return ''; - return shown?textOnFn(shown):''; -} - // Turn a theme name into a safe filename slug: collapse runs of disallowed // characters to a single dash, trim leading/trailing dashes, fall back to 'theme'. function slugify(name){return name.replace(/[^A-Za-z0-9._-]+/g,'-').replace(/^-+|-+$/g,'')||'theme';} @@ -566,4 +555,4 @@ function composeHoverTitle(doc,base){ return doc||base; } -export { nameToHex, migrateLegacyFace, cssWeight, faceDecoration, boxCss, faceCss, composeHoverTitle, normalizePkgFace, buildPkgmap, packagesForExport, mergePackagesInto, effResolve, resolveSyntaxFg, resolveUiAttr, dropdownRowTextColor, paletteOptionList, galleryModel, appViewKeysSorted, faceBoxNonDefaults, overflowNonDefault, clampHeight, HEIGHT_MIN, HEIGHT_MAX, stepViewIndex, spanNeighborHex, slugify, fgSetFor, floor, lMax, COVERED_FACES, columnsFromPalette, usedPaletteHexes, paletteUsages, regenColumn, rankByLightness, stepRepointPlan, sortColumns, sortColumnMembers, groundRoleOfEntry, groundColumnMembersFromPalette, clearPalettePlan, deletePaletteColumnPlan, areAllLocked, lockToggleLabel, toggleLockSet }; +export { nameToHex, migrateLegacyFace, cssWeight, faceDecoration, boxCss, faceCss, composeHoverTitle, normalizePkgFace, buildPkgmap, packagesForExport, mergePackagesInto, effResolve, resolveSyntaxFg, resolveUiAttr, paletteOptionList, galleryModel, appViewKeysSorted, faceBoxNonDefaults, overflowNonDefault, clampHeight, HEIGHT_MIN, HEIGHT_MAX, stepViewIndex, spanNeighborHex, slugify, fgSetFor, floor, lMax, COVERED_FACES, columnsFromPalette, usedPaletteHexes, paletteUsages, regenColumn, rankByLightness, stepRepointPlan, sortColumns, sortColumnMembers, groundRoleOfEntry, groundColumnMembersFromPalette, clearPalettePlan, deletePaletteColumnPlan, areAllLocked, lockToggleLabel, toggleLockSet }; diff --git a/scripts/theme-studio/test-app-core.mjs b/scripts/theme-studio/test-app-core.mjs index cdfa0bc1e..09ddf5aec 100644 --- a/scripts/theme-studio/test-app-core.mjs +++ b/scripts/theme-studio/test-app-core.mjs @@ -7,7 +7,7 @@ import assert from 'node:assert/strict'; import { readFileSync } from 'node:fs'; import { fileURLToPath } from 'node:url'; import { - nameToHex, migrateLegacyFace, normalizePkgFace, buildPkgmap, packagesForExport, mergePackagesInto, effResolve, resolveSyntaxFg, resolveUiAttr, dropdownRowTextColor, paletteOptionList, spanNeighborHex, slugify, + nameToHex, migrateLegacyFace, normalizePkgFace, buildPkgmap, packagesForExport, mergePackagesInto, effResolve, resolveSyntaxFg, resolveUiAttr, paletteOptionList, spanNeighborHex, slugify, clearPalettePlan, deletePaletteColumnPlan, groundColumnMembersFromPalette, areAllLocked, lockToggleLabel, toggleLockSet, galleryModel, appViewKeysSorted, faceBoxNonDefaults, overflowNonDefault, stepViewIndex, cssWeight, faceDecoration, boxCss, faceCss, composeHoverTitle, @@ -901,23 +901,6 @@ test('resolveUiAttr: a face with no inherit and an unset attribute returns null' assert.equal(resolveUiAttr('region', 'bg', { 'region': { bg: null } }), null); }); -// dropdownRowTextColor: a popup row showing a real palette color inherits the -// popup foreground (legible on the fixed dark popup); only the filled default -// row uses a contrast color against its own background. textOn is stubbed so the -// test asserts the decision, not the contrast math. -const stubTextOn = (h) => (h === '#000000' ? '#fff' : '#000'); -test('dropdownRowTextColor: a real palette color inherits the popup fg (empty)', () => { - assert.equal(dropdownRowTextColor('#2a3a5a', '#2a3a5a', stubTextOn), ''); -}); -test('dropdownRowTextColor: a dark swatch still inherits (regression: blues were unreadable)', () => { - assert.equal(dropdownRowTextColor('#000000', '#000000', stubTextOn), ''); -}); -test('dropdownRowTextColor: the filled default row contrasts against its fill', () => { - assert.equal(dropdownRowTextColor('', '#cdced1', stubTextOn), '#000'); -}); -test('dropdownRowTextColor: a default row with no fill inherits (empty)', () => { - assert.equal(dropdownRowTextColor('', '', stubTextOn), ''); -}); // appViewKeysSorted: the assignment-view dropdown lists package apps // alphabetically by display label, independent of the APPS build order diff --git a/scripts/theme-studio/theme-studio.html b/scripts/theme-studio/theme-studio.html index 97c36554e..dada0d2c9 100644 --- a/scripts/theme-studio/theme-studio.html +++ b/scripts/theme-studio/theme-studio.html @@ -693,17 +693,6 @@ function resolveUiAttr(face,attr,uimap){ return walkInheritChain(face,f=>UI_INHERIT[f],f=>uimap[f]&&uimap[f][attr]); } -// Text color for a swatch-dropdown popup row. A row showing a real palette color -// sits on the popup's own fixed background, so its name/hex text must inherit the -// popup foreground (return '' to use the CSS color). Coloring it for contrast -// against the swatch instead picks near-black text for a mid/dark swatch, which -// is unreadable on the dark popup. Only the "default" row, filled solid with -// SHOWN, uses a contrast color computed against that fill. -function dropdownRowTextColor(hex,shown,textOnFn){ - if(hex)return ''; - return shown?textOnFn(shown):''; -} - // Turn a theme name into a safe filename slug: collapse runs of disallowed // characters to a single dash, trim leading/trailing dashes, fall back to 'theme'. function slugify(name){return name.replace(/[^A-Za-z0-9._-]+/g,'-').replace(/^-+|-+$/g,'')||'theme';} -- cgit v1.2.3