aboutsummaryrefslogtreecommitdiff
path: root/scripts/theme-studio/app.js
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-20 05:33:44 -0400
committerCraig Jennings <c@cjennings.net>2026-06-20 05:33:44 -0400
commit6a2385af4566173df8e9cda28f9dd112545d0cf9 (patch)
tree832084ac1df02d245389f1ab3fc357f480e42bca /scripts/theme-studio/app.js
parenta267a113706fc83af9c52268daf8d9d07e468124 (diff)
downloaddotemacs-6a2385af4566173df8e9cda28f9dd112545d0cf9.tar.gz
dotemacs-6a2385af4566173df8e9cda28f9dd112545d0cf9.zip
feat(theme-studio): sort the language dropdown and add nav arrows
Sort the language list alphabetically and pin Elisp as the default selection. Add the ‹ › arrows flanking the dropdown that step the selection (clamped, no wrap), reusing the view-dropdown's stepViewIndex so you can walk languages without reopening the menu.
Diffstat (limited to 'scripts/theme-studio/app.js')
-rw-r--r--scripts/theme-studio/app.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/scripts/theme-studio/app.js b/scripts/theme-studio/app.js
index e21e48fe..d6375eee 100644
--- a/scripts/theme-studio/app.js
+++ b/scripts/theme-studio/app.js
@@ -47,7 +47,7 @@ function effBg(v){return v||MAP['bg'];}
// fg:MAP['p']} repeated across app.js, palette-actions.js, and the browser gates.
function groundPair(){return {bg:MAP['bg'],fg:MAP['p']};}
function cid(l){return l.replace(/\W/g,'');}
-function buildLangSel(){const s=document.getElementById('langsel');s.innerHTML='';for(const lang in SAMPLES){const o=document.createElement('option');o.value=lang;o.textContent=lang;s.appendChild(o);}}
+function buildLangSel(){const s=document.getElementById('langsel');s.innerHTML='';for(const lang of Object.keys(SAMPLES).sort((a,b)=>a.localeCompare(b))){const o=document.createElement('option');o.value=lang;o.textContent=lang;s.appendChild(o);}if(SAMPLES['Elisp'])s.value='Elisp';}
function renderCode(){
const lang=document.getElementById('langsel').value;let html='';
for(const line of SAMPLES[lang]){
@@ -605,6 +605,13 @@ function stepView(dir){
const i=stepViewIndex(s.selectedIndex,s.options.length,dir);
if(i!==s.selectedIndex){s.selectedIndex=i;onViewChange();}
}
+// The ‹ › buttons flanking the language dropdown step the selection by DIR and
+// re-render the code sample + package preview, mirroring the view-dropdown nav.
+function stepLang(dir){
+ const s=document.getElementById('langsel');if(!s)return;
+ const i=stepViewIndex(s.selectedIndex,s.options.length,dir);
+ if(i!==s.selectedIndex){s.selectedIndex=i;renderCode();buildPkgPreview();}
+}
function onViewChange(){const s=document.getElementById('viewsel');const v=(s&&s.value)||'@code';
const show=(id,on)=>{const e=document.getElementById(id);if(e)e.style.display=on?'':'none';};
show('view-code',v==='@code');show('view-ui',v==='@ui');show('view-pkg',v[0]!=='@');