Created
November 16, 2016 21:57
-
-
Save douglascayers/f8531ca71367f12e85da8a56e9f793b9 to your computer and use it in GitHub Desktop.
DEV601: Exercise 5.1 alternative solution to closing modal dialog. Note line 14 in .cmp which wraps the original solution. Controller adds 'slds-hide' class without us needing to define our own *.style resource.
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
<aura:component> | |
<aura:attribute name="title" type="String" required="true" /> | |
<aura:attribute name="closeable" type="Boolean" default="true"/> | |
<aura:attribute name="closeLabel" type="String" default="Close"/> | |
<aura:attribute name="cancelLabel" type="String" default="Cancel"/> | |
<aura:attribute name="confirmLabel" type="String" default="OK"/> | |
<aura:attribute name="onclose" type="Aura.Action" default="{!c.defaultCloseAction}"/> | |
<aura:attribute name="oncancel" type="Aura.Action" default="{!c.defaultCloseAction}"/> | |
<aura:attribute name="onconfirm" type="Aura.Action" default="{!c.defaultCloseAction}"/> | |
<div aura:id="modalDialogContainer"> | |
<div role="dialog" tabindex="-1" class="slds-modal slds-fade-in-open"> | |
<div class="slds-modal__container"> | |
<div class="slds-modal__header"> | |
<aura:if isTrue="{!v.closeable}"> | |
<lightning:buttonIcon | |
class="slds-modal__close" | |
iconName="utility:close" | |
size="large" | |
variant="bare-inverse" | |
alternativeText="{!v.closeLabel}" | |
onclick="{!v.onclose}"/> | |
</aura:if> | |
<h2 class="slds-text-heading--medium">{!v.title}</h2> | |
</div> | |
<div class="slds-modal__content slds-p-around--medium"> | |
<div> | |
{!v.body} | |
</div> | |
</div> | |
<div class="slds-modal__footer"> | |
<aura:if isTrue="{!not(empty(v.cancelLabel))}"> | |
<lightning:button label="{!v.cancelLabel}" | |
variant="neutral" | |
onclick="{!v.oncancel}"/> | |
</aura:if> | |
<aura:if isTrue="{!not(empty(v.confirmLabel))}"> | |
<lightning:button label="{!v.confirmLabel}" | |
variant="brand" | |
onclick="{!v.onconfirm}"/> | |
</aura:if> | |
</div> | |
</div> | |
</div> | |
<div class="slds-backdrop slds-backdrop--open"></div> | |
</div> | |
</aura:component> |
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
({ | |
defaultCloseAction : function(component, event, helper) { | |
$A.util.addClass( component.find('modalDialogContainer'), 'slds-hide' ); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment