Smartened the button toggle logic. Could be smarter, though.

This commit is contained in:
PeekabooSteam 2023-03-10 13:39:40 +00:00
parent ecaf646375
commit ceec65fb37
2 changed files with 9 additions and 8 deletions

View File

@ -372,6 +372,11 @@ nav.ol-panel> :last-child {
}
.ol-panel .ol-group-button-toggle button.off::before {
background-image: url("/images/icons/square-regular.svg");
}
.highlight-primary {
@ -626,12 +631,6 @@ body[data-hide-naval] #unit-visibility-control-naval {
}
[data-hide-blue] #coalition-visibility-control #coalition-visibility-control-blue::before,
[data-hide-red] #coalition-visibility-control #coalition-visibility-control-red::before,
[data-hide-neutral] #coalition-visibility-control #coalition-visibility-control-neutral::before {
background-image: url("/images/icons/square-regular.svg");
}
.toggle {
--width: 40px;
--height: calc(var(--width) / 2);

View File

@ -75,11 +75,12 @@ function setup() {
if ( triggerElement instanceof HTMLElement ) {
const eventName:string = triggerElement.dataset.onClick || "";
const params:string = triggerElement.dataset.onClickParams || "{}";
let params = JSON.parse( triggerElement.dataset.onClickParams || "{}" );
params._element = triggerElement;
if ( eventName ) {
document.dispatchEvent( new CustomEvent( eventName, {
detail: JSON.parse( params )
detail: params
} ) );
}
@ -130,6 +131,7 @@ function setup() {
document.addEventListener( "toggleCoalitionVisibility", ( ev:CustomEventInit ) => {
ev.detail._element.classList.toggle( "off" );
document.body.toggleAttribute( "data-hide-" + ev.detail.coalition );
});