aboutsummaryrefslogtreecommitdiff
path: root/scripts/theme-studio/test-app-core.mjs
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-16 06:27:08 -0500
committerCraig Jennings <c@cjennings.net>2026-06-16 06:27:08 -0500
commit5551f9e9bccc68dad61edf5d3500cd6149abe05d (patch)
treea00537dfc2152777e7822b27604d3bf4ed4d709c /scripts/theme-studio/test-app-core.mjs
parent0b640358c287e908753e6dcd32b1583ad45b2ce9 (diff)
downloaddotemacs-5551f9e9bccc68dad61edf5d3500cd6149abe05d.tar.gz
dotemacs-5551f9e9bccc68dad61edf5d3500cd6149abe05d.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.mjs19
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 20f3d573..8f62ae55 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);
+});