Untitled
unknown
plain_text
2 years ago
1.4 kB
5
Indexable
Never
$w.onReady(function () { //DEFINE ACTIVE AND INACTIVE BUTTON COLORS 🤩 const whiteColor = "#FFFFFF"; const textColorActive = "#00AD63"; const greyColor = "#FAFAFA"; const textColorInactive = "#74767E"; //ONCLICK FUNCTIONS FOR EACH BUTTONS. CHANGE STATE ✨ $w('#firstButton').onClick(() => { $w('#stateElementId').changeState("firstState"); }); $w('#secondButton').onClick(() => { $w('#stateElementId').changeState("secondState"); }); $w('#thirdButton').onClick(() => { $w('#stateElementId').changeState("thirdState"); }); //CHANGE BUTTON COLORS IF THEY ARE ACTIVE OR NOT 🎉 $w("#stateElementId").onChange((event) => { const buttonNames = ["first", "second", "third"]; buttonNames.forEach(buttonName => { let button = $w("#" + buttonName + "Button"); let state = buttonName + "State"; let line = $w("#" + buttonName + "Line"); if (event.target.currentState.id === state) { button.style.backgroundColor = whiteColor; button.style.color = textColorActive; line.show(); } else { button.style.backgroundColor = greyColor; button.style.color = textColorInactive; line.hide(); } }); }); });