Made feature switches automatically toggle a document.body classname.

This commit is contained in:
PeekabooSteam 2023-03-08 11:03:48 +00:00
parent 931b1ea537
commit 6c488dba63
2 changed files with 5 additions and 8 deletions

View File

@ -49,7 +49,7 @@ body {
z-index: 1000;
}
body.forceShowUnitControlPanel #unit-control-panel {
body.feature-forceShowUnitControlPanel #unit-control-panel {
display:block !important;
}

View File

@ -86,10 +86,7 @@ export class FeatureSwitches {
"defaultEnabled": false,
"label": "Force show unit control panel",
"masterSwitch": true,
"name": "forceShowUnitControlPanel",
"onEnabled": function() {
document.body.classList.add( "forceShowUnitControlPanel" );
}
"name": "forceShowUnitControlPanel"
})
];
@ -118,12 +115,9 @@ export class FeatureSwitches {
if ( featureSwitch.isEnabled() ) {
if ( typeof featureSwitch.onEnabled === "function" ) {
featureSwitch.onEnabled();
}
} else {
document.querySelectorAll( "[data-feature-switch='" + featureSwitch.name + "']" ).forEach( el => {
@ -137,6 +131,9 @@ export class FeatureSwitches {
});
}
document.body.classList.toggle( "feature-" + featureSwitch.name, featureSwitch.isEnabled() );
}
}