You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, addTab only support title attribute, which is pushed into the Dom as innerText (i think), not innerHTML. So we can't put our title in a span or use google material symbols icons without a little hack.
Hack:
installTabs() {
// let's add an "icon" attribute
const pages = [
{ title:'General', icon:'page_info', },
{ title:'Layers', icon:'layers' },
{ title:'Lights', icon:'lightbulb' },
{ title:'Config', icon:'settings_applications' }
];
// this.gui is an instance of tweakpane
this.tabs = this.gui.addTab({ pages } );
this.tabGeneral = this.tabs.pages[0];
this.tabLayers = this.tabs.pages[1];
this.tabLights = this.tabs.pages[2];
this.tabConfig = this.tabs.pages[3];
// update tab title with icons if needed
let i = 0;
document.querySelectorAll('.tp-tbiv_t').forEach(el => {
if (pages[i].icon) {
el.innerHTML = `<i class="msy-sharp" title="${el.innerText}">${pages[i].icon}</i>`;
}
i++;
});
}
It should be great to be able to set HTML directly in pages elements, i.e
The security risk is minor because tabs title are defined by the developer. But tabs title (or icons) can come from a database or outside too, who know's ... so ...
Hi !
Currently, addTab only support
title
attribute, which is pushed into the Dom as innerText (i think), not innerHTML. So we can't put our title in a span or use google material symbols icons without a little hack.Hack:
It should be great to be able to set HTML directly in pages elements, i.e
What do you think ?
I was using DAT.gui, then lil-gui, now definitively switched to tweakpane. Great job !
The text was updated successfully, but these errors were encountered: