diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-13 17:57:30 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-13 17:57:30 -0500 |
| commit | 237ab428f5f2c719f4c6cf2624c7e223c16945e6 (patch) | |
| tree | a29aa2d394c2a282feb01f08aa01a199356610c4 /scripts/theme-studio | |
| parent | 060e08a90daef6dbd36464d7e21c0a5a3094d8d4 (diff) | |
| download | dotemacs-237ab428f5f2c719f4c6cf2624c7e223c16945e6.tar.gz dotemacs-237ab428f5f2c719f4c6cf2624c7e223c16945e6.zip | |
Fix theme studio fg endpoint selection
Diffstat (limited to 'scripts/theme-studio')
| -rw-r--r-- | scripts/theme-studio/browser-gates.js | 11 | ||||
| -rw-r--r-- | scripts/theme-studio/palette-actions.js | 7 | ||||
| -rw-r--r-- | scripts/theme-studio/theme-studio.html | 18 |
3 files changed, 30 insertions, 6 deletions
diff --git a/scripts/theme-studio/browser-gates.js b/scripts/theme-studio/browser-gates.js index 77314217..b22eee97 100644 --- a/scripts/theme-studio/browser-gates.js +++ b/scripts/theme-studio/browser-gates.js @@ -312,11 +312,18 @@ if(location.hash==='#columntest'||location.hash==='#familytest'){let ok=true;con A(strips[0].querySelectorAll('.pchip').length===2,'ground column carries bg + fg endpoints'); A(!!strips[0].querySelector('.fhead + .fcount + .pchip'),'span control sits between header and tiles for ground'); A(strips.length>=4,'ground + red + blue + gray columns, got '+strips.length); - const blueHead=strips.find(s=>s.dataset.column==='blue')&&strips.find(s=>s.dataset.column==='blue').querySelector('.ctitle'); + PALETTE=[['#3a6ea5','blue','blue']];MAP['bg']='#0d0b0a';MAP['p']='#f0fef0';selectedIdx=null;renderPalette(); + const fgChip=[...document.querySelectorAll('#pals .fstrip[data-column="ground"] .pchip')].find(c=>c.querySelector('.nm')&&c.querySelector('.nm').value==='fg'); + A(!!fgChip&&!fgChip.querySelector('.nm').disabled,'missing fg endpoint is normalized into a selectable real chip'); + if(fgChip)fgChip.click(); + A(selectedIdx!==null&&PALETTE[selectedIdx]&&PALETTE[selectedIdx][1]==='fg'&&document.getElementById('newhexstr').value.toLowerCase()==='#f0fef0','clicking normalized fg selects it and updates the color editor'); + PALETTE=[['#0d0b0a','ground'],['#f0fef0','fg'],['#c0402a','red'],['#3a6ea5','blue'],['#808080','gray']];selectedIdx=null;renderPalette(); + const resetStrips=[...document.querySelectorAll('#pals .fstrip')]; + const blueHead=resetStrips.find(s=>s.dataset.column==='blue')&&resetStrips.find(s=>s.dataset.column==='blue').querySelector('.ctitle'); A(!!blueHead,'normal column header has a selectable title'); if(blueHead)blueHead.click(); A(selectedIdx!==null&&PALETTE[selectedIdx][1]==='blue'&&document.getElementById('newhexstr').value.toLowerCase()==='#3a6ea5','clicking a column title selects its base color'); - const blueRight=strips.find(s=>s.dataset.column==='blue')&&strips.find(s=>s.dataset.column==='blue').querySelector('.cmove.right'); + const blueRight=resetStrips.find(s=>s.dataset.column==='blue')&&resetStrips.find(s=>s.dataset.column==='blue').querySelector('.cmove.right'); if(blueRight)blueRight.click(); const moved=[...document.querySelectorAll('#pals .fstrip')].map(s=>s.dataset.column); A(moved.indexOf('blue')>moved.indexOf('gray'),'right arrow moves a color column after its neighbor'); diff --git a/scripts/theme-studio/palette-actions.js b/scripts/theme-studio/palette-actions.js index a7b3b28e..11f37d2f 100644 --- a/scripts/theme-studio/palette-actions.js +++ b/scripts/theme-studio/palette-actions.js @@ -28,7 +28,12 @@ function normalizePaletteEntry(entry){ const hex=entry&&entry[0],name=(entry&&entry[1])||'color'; return [hex,name,(entry&&entry[2])||columnIdOf(entry)]; } -function normalizePalette(){PALETTE=PALETTE.map(normalizePaletteEntry);} +function ensureGroundEndpoints(){ + const ground={bg:MAP['bg'],fg:MAP['p']}; + if(ground.bg&&!PALETTE.some(entry=>groundRoleOfEntry(entry,ground)==='bg'))PALETTE.unshift([ground.bg,'bg','ground']); + if(ground.fg&&!PALETTE.some(entry=>groundRoleOfEntry(entry,ground)==='fg'))PALETTE.push([ground.fg,'fg','ground']); +} +function normalizePalette(){PALETTE=PALETTE.map(normalizePaletteEntry);ensureGroundEndpoints();} // The ground column is explicit: bg pins the top endpoint, fg pins the bottom // endpoint, and generated ground-N steps live between them. function groundColumnMembers(){ diff --git a/scripts/theme-studio/theme-studio.html b/scripts/theme-studio/theme-studio.html index 6ab689c0..8674efc0 100644 --- a/scripts/theme-studio/theme-studio.html +++ b/scripts/theme-studio/theme-studio.html @@ -896,7 +896,12 @@ function normalizePaletteEntry(entry){ const hex=entry&&entry[0],name=(entry&&entry[1])||'color'; return [hex,name,(entry&&entry[2])||columnIdOf(entry)]; } -function normalizePalette(){PALETTE=PALETTE.map(normalizePaletteEntry);} +function ensureGroundEndpoints(){ + const ground={bg:MAP['bg'],fg:MAP['p']}; + if(ground.bg&&!PALETTE.some(entry=>groundRoleOfEntry(entry,ground)==='bg'))PALETTE.unshift([ground.bg,'bg','ground']); + if(ground.fg&&!PALETTE.some(entry=>groundRoleOfEntry(entry,ground)==='fg'))PALETTE.push([ground.fg,'fg','ground']); +} +function normalizePalette(){PALETTE=PALETTE.map(normalizePaletteEntry);ensureGroundEndpoints();} // The ground column is explicit: bg pins the top endpoint, fg pins the bottom // endpoint, and generated ground-N steps live between them. function groundColumnMembers(){ @@ -2062,11 +2067,18 @@ if(location.hash==='#columntest'||location.hash==='#familytest'){let ok=true;con A(strips[0].querySelectorAll('.pchip').length===2,'ground column carries bg + fg endpoints'); A(!!strips[0].querySelector('.fhead + .fcount + .pchip'),'span control sits between header and tiles for ground'); A(strips.length>=4,'ground + red + blue + gray columns, got '+strips.length); - const blueHead=strips.find(s=>s.dataset.column==='blue')&&strips.find(s=>s.dataset.column==='blue').querySelector('.ctitle'); + PALETTE=[['#3a6ea5','blue','blue']];MAP['bg']='#0d0b0a';MAP['p']='#f0fef0';selectedIdx=null;renderPalette(); + const fgChip=[...document.querySelectorAll('#pals .fstrip[data-column="ground"] .pchip')].find(c=>c.querySelector('.nm')&&c.querySelector('.nm').value==='fg'); + A(!!fgChip&&!fgChip.querySelector('.nm').disabled,'missing fg endpoint is normalized into a selectable real chip'); + if(fgChip)fgChip.click(); + A(selectedIdx!==null&&PALETTE[selectedIdx]&&PALETTE[selectedIdx][1]==='fg'&&document.getElementById('newhexstr').value.toLowerCase()==='#f0fef0','clicking normalized fg selects it and updates the color editor'); + PALETTE=[['#0d0b0a','ground'],['#f0fef0','fg'],['#c0402a','red'],['#3a6ea5','blue'],['#808080','gray']];selectedIdx=null;renderPalette(); + const resetStrips=[...document.querySelectorAll('#pals .fstrip')]; + const blueHead=resetStrips.find(s=>s.dataset.column==='blue')&&resetStrips.find(s=>s.dataset.column==='blue').querySelector('.ctitle'); A(!!blueHead,'normal column header has a selectable title'); if(blueHead)blueHead.click(); A(selectedIdx!==null&&PALETTE[selectedIdx][1]==='blue'&&document.getElementById('newhexstr').value.toLowerCase()==='#3a6ea5','clicking a column title selects its base color'); - const blueRight=strips.find(s=>s.dataset.column==='blue')&&strips.find(s=>s.dataset.column==='blue').querySelector('.cmove.right'); + const blueRight=resetStrips.find(s=>s.dataset.column==='blue')&&resetStrips.find(s=>s.dataset.column==='blue').querySelector('.cmove.right'); if(blueRight)blueRight.click(); const moved=[...document.querySelectorAll('#pals .fstrip')].map(s=>s.dataset.column); A(moved.indexOf('blue')>moved.indexOf('gray'),'right arrow moves a color column after its neighbor'); |
