/
strike_carousel.cmp
126 lines (109 loc) · 6.91 KB
/
strike_carousel.cmp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<!--
Strike by Appiphony
Version: 0.10.1
Website: http://www.lightningstrike.io
GitHub: https://github.com/appiphony/Strike-Components
License: BSD 3-Clause License
-->
<aura:component >
<aura:handler name="init" value="{!this}" action="{!c.onInit}"/>
<!-- External -->
<aura:attribute name="iconName" type="String" default="standard:carousel"/>
<aura:attribute name="title" type="String" default="Cards"/>
<aura:attribute name="showTotal" type="Boolean" default="{!true}"/>
<aura:attribute name="cards" type="Map[]"/>
<!-- /External -->
<!-- Internal -->
<aura:attribute name="pages" type="Integer[]"/>
<aura:attribute name="spacers" type="Integer[]"/>
<aura:attribute name="containerWidth" type="Integer" default="480"/>
<aura:attribute name="currentPage" type="Integer" default="0"/>
<aura:handler name="change" value="{!v.currentPage}" action="{!c.handleChangeCurrentPage}"/>
<!-- Internal -->
<aura:if isTrue="{!not(empty(v.cards))}">
<div class="slds-scope">
<div class="slds-box sc-p_none slds-theme_shade">
<aura:if isTrue="{!not(empty(v.title))}">
<header class="slds-card__header slds-media slds-media_center slds-has-flexi-truncate sc-carousel-header">
<aura:if isTrue="{!not(empty(v.iconName))}">
<div class="slds-media__figure">
<lightning:icon iconName="{!v.iconName}" size="small" title="title" />
</div>
</aura:if>
<div class="slds-media__body">
<h2 class="slds-text-heading_small">{!v.title} <aura:if isTrue="{!v.showTotal}"> ({!v.cards.length})</aura:if></h2>
</div>
</header>
</aura:if>
<!-- Empty State -->
<aura:if isTrue="{!not(v.cards.length gt 0)}">
<div class="slds-p-horizontal_small slds-text-align_center slds-m-bottom_xx-large slds-p-top_xxx-small"><em class="slds-text-color_weak">No records to display</em></div>
</aura:if>
<!-- /Empty State -->
<div class="{!'slds-grid slds-align_absolute-center slds-p-horizontal_medium' + if(empty(v.title), ' slds-m-top_medium', '')}">
<!-- Previous Button -->
<aura:if isTrue="{!and(v.containerWidth gt 480, v.cards.length gt 3)}">
<div class="slds-col slds-no-flex slds-p-right_x-small">
<lightning:buttonIcon iconName="utility:chevronleft" alternativeText="Previous" size="small" variant="border-filled" onclick="{!c.handleClickPrevious}" />
</div>
</aura:if>
<!-- /Previous Button -->
<!-- Carousel Body -->
<div class="slds-col slds-scrollable_none">
<div aura:id="carousel-body" class="{!'sc-carousel-body slds-grid slds-grid_vertical-stretch slds-scrollable_none' + if(v.containerWidth lt 481, ' slds-wrap', '') + if(or(v.cards.length lt 4, v.containerWidth lt 481), ' slds-grid_pull-padded-x-small', '')}">
<aura:iteration items="{!v.cards}" var="card">
<!-- Card -->
<div class="{!'slds-col slds-no-flex slds-p-horizontal_x-small' + if(v.containerWidth gt 480, ' slds-size_1-of-3', ' slds-size_1-of-1') + if(or(v.cards.length lt 4, v.containerWidth lt 481), ' slds-m-bottom_medium', '')}">
{!card}
</div>
<!-- /Card -->
</aura:iteration>
<aura:iteration items="{!v.spacers}" var="spacer">
<!-- Spacer -->
<div class="slds-col slds-no-flex slds-size_1-of-3 slds-p-horizontal_x-small"></div>
<!-- /Spacer -->
</aura:iteration>
</div>
</div>
<!-- /Carousel Body -->
<!-- Next Button -->
<aura:if isTrue="{!and(v.containerWidth gt 480, v.cards.length gt 3)}">
<div class="slds-col slds-no-flex slds-p-left_x-small">
<lightning:buttonIcon iconName="utility:chevronright" alternativeText="Next" size="small" variant="border-filled" onclick="{!c.handleClickNext}" />
</div>
</aura:if>
<!-- /Next Button -->
</div>
<!-- Pagination -->
<aura:if isTrue="{!and(v.containerWidth gt 480, v.cards.length gt 3)}">
<div class="slds-m-around_small">
<ul class="sc-pagination">
<aura:iteration items="{!v.pages}" var="page" indexVar="index">
<li><a aura:id="dot" href="javascript:void(0);" class="{!'sc-pagination__dot' + if(v.currentPage == index, ' sc-pagination__dot_selected', '')}" data-page="{!index}" onclick="{!c.handleClickDot}"></a></li>
</aura:iteration>
</ul>
</div>
</aura:if>
<!-- /Pagination -->
</div>
</div>
</aura:if>
</aura:component>
<!--
Copyright 2017 Appiphony, LLC
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->