-
Notifications
You must be signed in to change notification settings - Fork 3
/
caribou-step-action-buttons.html
199 lines (170 loc) · 6.47 KB
/
caribou-step-action-buttons.html
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<link rel="import" href="../polymer/polymer-element.html">
<link rel="import" href="../paper-button/paper-button.html">
<dom-module id="caribou-step-action-buttons">
<template>
<style>
:host {
display: block;
}
paper-button {
--paper-button-ink-color: var(--button-ink-color);
color: #fff;
background-color: var(--primary-color);
@apply --button-style;
margin: 0;
}
</style>
<paper-button id="updateBtn" data-event="update" hidden="[[!isUpdate]]" on-tap="_fireEvent">{{updateLabel}}</paper-button>
<paper-button id="continueBtn" data-event="continue" hidden="[[__isContinueHidden]]" on-tap="_fireEvent">{{continueLabel}}</paper-button>
<paper-button id="skipBtn" data-event="skip" hidden="[[!skipButton]]" on-tap="_fireEvent">{{skipLabel}}</paper-button>
<paper-button id="finishBtn" data-event="finish" hidden="[[!isFinish]]" on-tap="_fireEvent">{{finishLabel}}</paper-button>
<paper-button id="backBtn" data-event="back" hidden="[[!backButton]]" on-tap="_fireEvent">{{backLabel}}</paper-button>
</template>
<script>
/**
* `caribou-step-action-buttons` is an element used to display a panel of action button used to navigate through the stepper.
* These button fires each one an event.
*
* To change the label of each button, refer to the `caribou-step` element.
*
* Custom property | Description | Default
* ----------------|-------------|----------
* `--button-ink-color` | Background color of the ripple | `Based on the button's color`
* `--button-style` | Mixin applied to the button. Refer `paper-button` element for more details. | `{}`
*
* @polymer
* @customElement
* @element caribou-step-action-buttons
*/
class CaribouStepActionButtonsElement extends Polymer.Element {
/**
* Fired when the continue button is clicked.
*
* @event continue-clicked
* @param {Object} detail empty
*/
/**
* Fired when the skip button is clicked.
*
* @event skip-clicked
* @param {Object} detail empty
*/
/**
* Fired when the update button is clicked.
*
* @event update-clicked
* @param {Object} detail empty
*/
/**
* Fired when the finish button is clicked.
*
* @event finish-clicked
* @param {Object} detail empty
*/
/**
* Fired when the back button is clicked.
*
* @event back-clicked
* @param {Object} detail empty
*/
static get is() {
return 'caribou-step-action-buttons';
}
static get properties() {
return {
skipButton: {
type: Boolean,
value: false
},
backButton: {
type: Boolean,
value: false
},
isUpdate: {
type: Boolean,
value: false,
observer: 'setContinueHidden'
},
__isContinueHidden: {
type: Boolean,
value: false
},
isFinish: {
type: Boolean,
value: false,
observer: 'setContinueHidden'
},
/**
* The back button text value
*/
backLabel: String,
/**
* The continue button text value
*/
continueLabel: String,
/**
* The skip button text value
*/
skipLabel: String,
/**
* The skip button text value
*/
finishLabel: String,
/**
* The skip button text value
*/
updateLabel: String
};
}
/**
* This function is used to set the 'isFinish' property.
* @param {Boolean} value true or false
*/
setFinish(value) {
this.isFinish = value;
}
/**
* This function is used to set the 'isUpdate' property.
* @param {Boolean} value true or false
*/
setUpdate(value) {
this.isUpdate = value;
}
/**
* This is a callback function called when one of the different button is clicked.
* @param {Object} e The event object
*/
_fireEvent(e) {
var eventName = e.currentTarget.dataset.event;
this.dispatchEvent(new CustomEvent(eventName + '-clicked', {
bubbles: true,
composed: true
}));
}
/**
* This function is used to set the '__isContinueHidden' property.
* @param {Boolean} value true to hide the continue button, false otherwise.
*/
setContinueHidden(value) {
if (value)
this.__isContinueHidden = true;
else
this.__isContinueHidden = false;
}
/**
* This function is used to reinitialize all the parameter of this element.
*/
reset() {
this.setContinueHidden(false);
this.setFinish(false);
this.setUpdate(false);
}
}
window.customElements.define(CaribouStepActionButtonsElement.is, CaribouStepActionButtonsElement);
/**
* @namespace Caribouflex
*/
window.Caribouflex = window.Caribouflex || {};
window.Caribouflex.CaribouStepActionButtonsElement = CaribouStepActionButtonsElement;
</script>
</dom-module>