aboutsummaryrefslogtreecommitdiff
path: root/scripts/theme-studio/browser-gates.js
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-15 19:19:38 -0500
committerCraig Jennings <c@cjennings.net>2026-06-15 19:19:38 -0500
commit7e7b871fe4f8daff724c3df37feb5572464532c1 (patch)
tree3dcfb0e760a22b460bc1188a9b6d7a6b5433a5a3 /scripts/theme-studio/browser-gates.js
parent5ab506d9b65a0d043c08690b86976b1f97889eaf (diff)
downloaddotemacs-7e7b871fe4f8daff724c3df37feb5572464532c1.tar.gz
dotemacs-7e7b871fe4f8daff724c3df37feb5572464532c1.zip
feat(theme-studio): flag unused palette tiles and columns
I added usedPaletteHexes, a reverse lookup over the syntax, ui, and package assignments (plus the ground endpoints) that resolves each reference to a hex. renderPalette outlines a tile whose color is referenced nowhere and outlines a whole column when none of its colors are used, so dead colors stand out for pruning before a theme ships. The check is biased safe: an unresolvable reference marks nothing, so a color that is actually used is never flagged. Node tests cover the lookup. A #unusedtest gate covers the tile and column flags.
Diffstat (limited to 'scripts/theme-studio/browser-gates.js')
-rw-r--r--scripts/theme-studio/browser-gates.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/scripts/theme-studio/browser-gates.js b/scripts/theme-studio/browser-gates.js
index bca2c7aff..b6aa1c4d0 100644
--- a/scripts/theme-studio/browser-gates.js
+++ b/scripts/theme-studio/browser-gates.js
@@ -729,3 +729,24 @@ if(location.hash==='#paltoggletest'){let ok=true;const notes=[];const A=(c,n)=>{
PALETTE=saveP;for(const k in MAP)delete MAP[k];Object.assign(MAP,saveM);syncSyntaxFromCache();renderPalette();
document.title='PALTOGGLETEST '+(ok?'PASS':'FAIL');
const d=document.createElement('div');d.id='paltoggletest';d.textContent='PALTOGGLETEST '+(ok?'PASS':'FAIL')+(notes.length?' fails='+notes.join(','):'');document.body.appendChild(d);}
+// Unused-tile gate (open with #unusedtest): a palette color referenced nowhere
+// in the theme gets the .unused flag; a column with no used members gets
+// .unused-col; referenced colors stay unflagged.
+if(location.hash==='#unusedtest'){let ok=true;const notes=[];const A=(c,n)=>{if(!c){ok=false;notes.push(n);}};
+ const saveP=PALETTE.slice(),saveM=Object.assign({},MAP),saveSyn=JSON.parse(JSON.stringify(SYNTAX)),saveU=JSON.parse(JSON.stringify(UIMAP));
+ setSyntaxFg('bg','#101010');setSyntaxFg('p','#f0f0f0');
+ PALETTE=[['#101010','bg','ground'],['#f0f0f0','fg','ground'],['#67809c','blue','blue'],['#123456','teal','teal']];
+ for(const f in UIMAP)UIMAP[f]={fg:null,bg:null,bold:false,italic:false,underline:false,strike:false};
+ setSyntaxFg('kw','#67809c');
+ renderPalette();
+ const tealStrip=document.querySelector('#pals .fstrip[data-column="teal"]');
+ const blueStrip=document.querySelector('#pals .fstrip[data-column="blue"]');
+ const tealChip=tealStrip&&tealStrip.querySelector('.pchip');
+ const blueChip=blueStrip&&blueStrip.querySelector('.pchip');
+ A(tealChip&&tealChip.classList.contains('unused'),'unreferenced-tile-flagged');
+ A(blueChip&&!blueChip.classList.contains('unused'),'referenced-tile-not-flagged');
+ A(tealStrip&&tealStrip.classList.contains('unused-col'),'all-unused-column-flagged');
+ A(blueStrip&&!blueStrip.classList.contains('unused-col'),'used-column-not-flagged');
+ PALETTE=saveP;for(const k in MAP)delete MAP[k];Object.assign(MAP,saveM);for(const k in SYNTAX)delete SYNTAX[k];Object.assign(SYNTAX,saveSyn);for(const f in UIMAP)delete UIMAP[f];Object.assign(UIMAP,saveU);syncSyntaxFromCache();renderPalette();
+ document.title='UNUSEDTEST '+(ok?'PASS':'FAIL');
+ const d=document.createElement('div');d.id='unusedtest';d.textContent='UNUSEDTEST '+(ok?'PASS':'FAIL')+(notes.length?' fails='+notes.join(','):'');document.body.appendChild(d);}