diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-16 06:27:08 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-16 06:27:08 -0500 |
| commit | bd75db78b08c8bffdfe47a69a26883f4f88ad1f9 (patch) | |
| tree | ca5811affbdc34f46bf3aba681547b0a429d76bf /scripts/theme-studio/test-app-core.mjs | |
| parent | 79d92d079016092149f79202edecff899a5c18e1 (diff) | |
| download | dotemacs-bd75db78b08c8bffdfe47a69a26883f4f88ad1f9.tar.gz dotemacs-bd75db78b08c8bffdfe47a69a26883f4f88ad1f9.zip | |
feat(theme-studio): prev/next arrows to step the view dropdown
I added left and right arrow buttons flanking the view dropdown. They step the selection to the previous or next item and re-render the faces table and preview, so you can walk the list without reopening the dropdown. A pure stepViewIndex helper clamps the index to the option range, no wrap. stepView sets the selection and calls onViewChange.
Diffstat (limited to 'scripts/theme-studio/test-app-core.mjs')
| -rw-r--r-- | scripts/theme-studio/test-app-core.mjs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/scripts/theme-studio/test-app-core.mjs b/scripts/theme-studio/test-app-core.mjs index 20f3d5734..8f62ae55a 100644 --- a/scripts/theme-studio/test-app-core.mjs +++ b/scripts/theme-studio/test-app-core.mjs @@ -9,7 +9,7 @@ import { fileURLToPath } from 'node:url'; import { nameToHex, normalizePkgFace, buildPkgmap, packagesForExport, mergePackagesInto, effResolve, resolveSyntaxFg, resolveUiAttr, dropdownRowTextColor, paletteOptionList, spanNeighborHex, slugify, clearPalettePlan, deletePaletteColumnPlan, groundColumnMembersFromPalette, areAllLocked, lockToggleLabel, toggleLockSet, - galleryModel, appViewKeysSorted, faceBoxNonDefaults, + galleryModel, appViewKeysSorted, faceBoxNonDefaults, stepViewIndex, } from './app-core.js'; import { planPaletteGenerator, entriesForGeneratedColumn } from './palette-generator-core.js'; import { oklch2hex, deltaE } from './colormath.js'; @@ -878,3 +878,20 @@ test('faceBoxNonDefaults: nullish inputs flag nothing', () => { assert.deepEqual(faceBoxNonDefaults(null, null), { fg: false, bg: false, style: false, inherit: false, height: false, box: false }); }); + +// stepViewIndex: the prev/next arrows step the view-dropdown selection, clamped +// to the option range (no wrap). +test('stepViewIndex: steps forward and back within range', () => { + assert.equal(stepViewIndex(2, 5, 1), 3); + assert.equal(stepViewIndex(2, 5, -1), 1); +}); +test('stepViewIndex: clamps at both ends, no wrap', () => { + assert.equal(stepViewIndex(0, 5, -1), 0); + assert.equal(stepViewIndex(4, 5, 1), 4); +}); +test('stepViewIndex: a single option or empty list stays put', () => { + assert.equal(stepViewIndex(0, 1, 1), 0); + assert.equal(stepViewIndex(0, 1, -1), 0); + assert.equal(stepViewIndex(3, 0, -1), 3); + assert.equal(stepViewIndex(0, 0, 1), 0); +}); |
