@eturnity/eturnity_reusable_components 9.25.16-panel-placement.1 → 9.25.16-panel-placement.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -157,6 +157,46 @@ describe('ButtonIcon.vue', () => {
|
|
|
157
157
|
}
|
|
158
158
|
})
|
|
159
159
|
|
|
160
|
+
it('replaces the icon with a spinner while loading', async () => {
|
|
161
|
+
expect(wrapper.find('[data-test-id="spinner_container"]').exists()).toBe(
|
|
162
|
+
false
|
|
163
|
+
)
|
|
164
|
+
expect(wrapper.findComponent({ name: 'Icon' }).exists()).toBe(true)
|
|
165
|
+
|
|
166
|
+
await wrapper.setProps({ isLoading: true })
|
|
167
|
+
expect(wrapper.find('[data-test-id="spinner_container"]').exists()).toBe(
|
|
168
|
+
true
|
|
169
|
+
)
|
|
170
|
+
expect(wrapper.findComponent({ name: 'Icon' }).exists()).toBe(false)
|
|
171
|
+
|
|
172
|
+
await wrapper.setProps({ isLoading: false })
|
|
173
|
+
expect(wrapper.find('[data-test-id="spinner_container"]').exists()).toBe(
|
|
174
|
+
false
|
|
175
|
+
)
|
|
176
|
+
expect(wrapper.findComponent({ name: 'Icon' }).props('name')).toBe(
|
|
177
|
+
'settings'
|
|
178
|
+
)
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
it('keeps rendering the text while loading', async () => {
|
|
182
|
+
await wrapper.setProps({ isLoading: true })
|
|
183
|
+
expect(wrapper.find('[data-test-id="button-icon-text"]').text()).toBe(
|
|
184
|
+
'Click Me'
|
|
185
|
+
)
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
it('renders a white spinner on types with white button text', async () => {
|
|
189
|
+
await wrapper.setProps({ isLoading: true, type: 'primary' })
|
|
190
|
+
expect(wrapper.findComponent({ name: 'NewSpinner' }).props('isWhite')).toBe(
|
|
191
|
+
true
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
await wrapper.setProps({ type: 'secondary' })
|
|
195
|
+
expect(wrapper.findComponent({ name: 'NewSpinner' }).props('isWhite')).toBe(
|
|
196
|
+
false
|
|
197
|
+
)
|
|
198
|
+
})
|
|
199
|
+
|
|
160
200
|
it('renders caret based on showCaret prop', async () => {
|
|
161
201
|
await wrapper.setProps({ showCaret: true })
|
|
162
202
|
let caret = wrapper.find('[data-test-id="button-icon-caret"]')
|
|
@@ -28,7 +28,9 @@
|
|
|
28
28
|
:type="type"
|
|
29
29
|
:variant="variant"
|
|
30
30
|
>
|
|
31
|
+
<RCSpinner v-if="isLoading" :is-white="isSpinnerWhite" size="tiny" />
|
|
31
32
|
<Icon
|
|
33
|
+
v-else
|
|
32
34
|
:color="getIconColor"
|
|
33
35
|
:disable-hover="disableIconHover"
|
|
34
36
|
:fill-type="fillType"
|
|
@@ -83,9 +85,11 @@
|
|
|
83
85
|
// iconName="external_icon"
|
|
84
86
|
// fontColor="white"
|
|
85
87
|
// fontSize="12px"
|
|
88
|
+
// :isLoading="false" // swaps the icon for a spinner
|
|
86
89
|
// />
|
|
87
90
|
|
|
88
91
|
import Icon from '../../icon'
|
|
92
|
+
import RCSpinner from '../../spinner'
|
|
89
93
|
import styled from 'vue3-styled-components'
|
|
90
94
|
import theme from '../../../assets/theme'
|
|
91
95
|
|
|
@@ -419,6 +423,7 @@
|
|
|
419
423
|
ButtonWrapper,
|
|
420
424
|
IconContainer,
|
|
421
425
|
Icon,
|
|
426
|
+
RCSpinner,
|
|
422
427
|
NumberContainer,
|
|
423
428
|
NumberText,
|
|
424
429
|
CountBadge,
|
|
@@ -541,11 +546,24 @@
|
|
|
541
546
|
default: false,
|
|
542
547
|
type: Boolean,
|
|
543
548
|
},
|
|
549
|
+
isLoading: {
|
|
550
|
+
required: false,
|
|
551
|
+
default: false,
|
|
552
|
+
type: Boolean,
|
|
553
|
+
},
|
|
544
554
|
},
|
|
545
555
|
computed: {
|
|
546
556
|
theme() {
|
|
547
557
|
return theme
|
|
548
558
|
},
|
|
559
|
+
// The spinner only offers white/purple, so pick whichever contrasts with
|
|
560
|
+
// the button background the same way the label already does.
|
|
561
|
+
isSpinnerWhite() {
|
|
562
|
+
return (
|
|
563
|
+
this.theme.mainButton[this.appTheme][this.type][this.variant].default
|
|
564
|
+
.textColor === this.theme.colors.white
|
|
565
|
+
)
|
|
566
|
+
},
|
|
549
567
|
getIconColor() {
|
|
550
568
|
if (this.iconColor) return this.iconColor
|
|
551
569
|
if (this.isDisabled) {
|
|
@@ -113,7 +113,8 @@
|
|
|
113
113
|
size: {
|
|
114
114
|
type: String,
|
|
115
115
|
default: 'medium',
|
|
116
|
-
validator: (value) =>
|
|
116
|
+
validator: (value) =>
|
|
117
|
+
['tiny', 'small', 'medium', 'large'].includes(value),
|
|
117
118
|
},
|
|
118
119
|
isWhite: {
|
|
119
120
|
required: false,
|