Created
May 1, 2019 02:56
-
-
Save sfdcale/05b7d0e8702e13081951d1e5828abc0c to your computer and use it in GitHub Desktop.
change button on click
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<button class={cssClass}> | |
<lightning-icon icon-name={iconName} onclick={handleToggleClick}>Non Profit</lightning-icon> | |
</button> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LightningElement, track} from 'lwc'; | |
export default class PcSelectButtonFramework extends LightningElement { | |
buttonClicked; //defaulted to false | |
@track cssClass = 'slds-button slds-button_neutral inactive'; | |
@track iconName = 'utility:preview'; | |
// Handles click on the 'Show/hide content' button | |
handleToggleClick() { | |
this.buttonClicked = !this.buttonClicked; //set to true if false, false if true. | |
this.cssClass = this.buttonClicked ? 'slds-button slds-button_neutral active' : 'slds-button slds-button_neutral inactive'; | |
this.iconName = this.buttonClicked ? 'utility:hide' : 'utility:preview'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment