Skip to content

Commit 365ac0a

Browse files
committed
refactor: rename negative props in components
1 parent 0f45839 commit 365ac0a

File tree

24 files changed

+137
-108
lines changed

24 files changed

+137
-108
lines changed

src/components/Dropdown/CDropdown.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ export default {
4949
addMenuClasses: [String, Array, Object],
5050
addTogglerClasses: [String, Array, Object],
5151
inNav: Boolean,
52-
noCaret: Boolean,
52+
caret: {
53+
type: Boolean,
54+
default: true
55+
},
5356
color: String,
5457
size: {
5558
type: String,
@@ -69,7 +72,10 @@ export default {
6972
},
7073
default: 'bottom-start'
7174
},
72-
noFlip: Boolean,
75+
flip: {
76+
type: Boolean,
77+
default: true
78+
},
7379
popperConfig: Object
7480
},
7581
data () {
@@ -131,7 +137,7 @@ export default {
131137
placement: this.placement,
132138
modifiers: {
133139
offset: { offset: this.offset || 0 },
134-
flip: { enabled: !this.noFlip }
140+
flip: { enabled: this.flip }
135141
}
136142
}
137143
},
@@ -170,7 +176,7 @@ export default {
170176
this.addTogglerClasses,
171177
this.inNav ? 'nav-link' : 'btn',
172178
{
173-
'dropdown-toggle': !this.noCaret && !this.split,
179+
'dropdown-toggle': this.caret && !this.split,
174180
[`btn-${this.size}`]: this.size && !this.inNav,
175181
'disabled' : this.disabled,
176182
[`${ this.inNav ? 'bg' : 'btn'}-${ this.color }`]: this.color

src/components/Dropdown/tests/CDropdown.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ const customWrapper = mount(Component, {
3030
addMenuClasses: 'additional-menu-class',
3131
addTogglerClasses: 'additional-toggler-class',
3232
inNav: false,
33-
noCaret: true,
33+
caret: false,
3434
color: 'success',
3535
size: 'lg',
3636
split: true,
3737
offset: 20,
3838
placement: 'right-end',
39-
noFlip: true,
39+
flip: false,
4040
},
4141
slots: {
4242
default: 'CDropdown subcomponents'
@@ -49,11 +49,11 @@ const navWrapper = mount(Component, {
4949
addMenuClasses: 'additional-menu-class',
5050
addTogglerClasses: 'additional-toggler-class',
5151
inNav: true,
52-
noCaret: true,
52+
caret: false,
5353
color: 'success',
5454
offset: 20,
5555
placement: 'left',
56-
noFlip: true
56+
flip: false
5757
},
5858
slots: {
5959
default: 'CDropdown subcomponents'

src/components/Grid/CRow.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { mergeData } from 'vue-functional-data-merge'
33
44
const props = {
55
tag: String,
6-
noGutters: Boolean,
6+
gutters: {
7+
type: Boolean,
8+
default: true
9+
},
710
alignVertical: {
811
type: String,
912
validator: str => ['', 'start', 'end', 'center','baseline', 'stretch'].includes(str)
@@ -24,7 +27,7 @@ export default {
2427
mergeData(data, {
2528
staticClass: 'row',
2629
class: {
27-
'no-gutters': props.noGutters,
30+
'no-gutters': !props.gutters,
2831
[`align-items-${props.alignVertical}`]: props.alignVertical,
2932
[`justify-content-${props.alignHorizontal}`]: props.alignHorizontal,
3033
}

src/components/Grid/tests/CRow.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const defaultWrapper = mount(Component)
66
const customWrapper = mount(Component, {
77
propsData: {
88
tag: 'header',
9-
noGutters: true,
9+
gutters: false,
1010
alignVertical: 'center',
1111
alignHorizontal: 'start'
1212
},

src/components/Image/CImgLazy.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ export default {
99
type: Number,
1010
default: 500
1111
},
12-
noFade: Boolean,
12+
fade: {
13+
type: Boolean,
14+
default: true
15+
},
1316
fadeOffset: {
1417
type: Number,
1518
default: -100
@@ -34,7 +37,7 @@ export default {
3437
},
3538
computed: {
3639
animationClasses () {
37-
return { 'opacity-0' : !this.noFade && !this.animated }
40+
return { 'opacity-0' : this.fade && !this.animated }
3841
},
3942
observerArgs () {
4043
if (this.active) {
@@ -53,7 +56,7 @@ export default {
5356
entries.forEach(entry => {
5457
if (entry.intersectionRatio > 0) {
5558
this.active = true
56-
if (!this.noFade) {
59+
if (this.fade) {
5760
this.$nextTick(() => {
5861
const animateInstantly = this.loadOffset <= this.fadeOffset
5962
animateInstantly ? this.queueAnimation() : this.defineObserver()

src/components/Image/tests/CImageLazy.spec.js renamed to src/components/Image/tests/CImgLazy.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ describe(ComponentName, () => {
5555
it('queueing animation observer on loading watcher properly', () => {
5656
const spy = jest.spyOn(customWrapper.vm, 'queueAnimation')
5757

58-
customWrapper.setProps({noFade: true})
58+
customWrapper.setProps({fade: false})
5959
customWrapper.vm.watchForLoading(triggeringEntry)
6060
expect(spy).not.toBeCalled()
6161

62-
customWrapper.setProps({noFade: false, fadeOffset: 600})
62+
customWrapper.setProps({fade: true, fadeOffset: 600})
6363
customWrapper.vm.watchForLoading(triggeringEntry)
6464
customWrapper.vm.$nextTick(() => expect(spy).toBeCalled())
6565
})

src/components/Modal/CModal.vue

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
>
99
<div :class="dialogClasses" role="document">
1010
<div :class="contentClasses">
11-
<slot v-if="!noHeader" name="header-wrapper"
12-
>
13-
<header class="modal-header">
11+
<slot name="header-wrapper">
12+
<header class="modal-header">
1413
<slot name="header">
1514
<h5 class="modal-title">
1615
{{title}}
@@ -26,12 +25,12 @@
2625
</slot>
2726
</header>
2827
</slot>
29-
<slot v-if="!noBody" name="body-wrapper">
28+
<slot name="body-wrapper">
3029
<div class="modal-body">
3130
<slot></slot>
3231
</div>
3332
</slot>
34-
<slot v-if="!noFooter" name="footer-wrapper">
33+
<slot name="footer-wrapper">
3534
<footer class="modal-footer">
3635
<slot name="footer">
3736
<button
@@ -55,7 +54,7 @@
5554
</div>
5655
</div>
5756
<div
58-
v-if="!noBackdrop && (visible || isTransitioning)"
57+
v-if="backdrop && (visible || isTransitioning)"
5958
:class="backdropClasses"
6059
>
6160
</div>
@@ -75,12 +74,18 @@ export default {
7574
},
7675
color: String,
7776
borderColor: String,
78-
noFade: Boolean,
79-
noBackdrop: Boolean,
80-
noCloseOnBackdrop: Boolean,
81-
noHeader: Boolean,
82-
noBody: Boolean,
83-
noFooter: Boolean,
77+
fade: {
78+
type: Boolean,
79+
default: true
80+
},
81+
backdrop: {
82+
type: Boolean,
83+
default: true
84+
},
85+
closeOnBackdrop: {
86+
type: Boolean,
87+
default: true
88+
},
8489
addModalClasses: [String, Array, Object],
8590
addDialogClasses: [String, Array, Object],
8691
addContentClasses: [String, Array, Object]
@@ -96,17 +101,16 @@ export default {
96101
backdropClasses () {
97102
return {
98103
'modal-backdrop': true,
99-
'fade': !this.noFade,
100-
'show': this.visible || this.noFade
104+
'fade': this.fade,
105+
'show': this.visible || !this.fade
101106
}
102107
},
103108
modalClasses () {
104109
return [
105110
'modal overflow-auto',
106111
this.addModalClasses,
107112
{
108-
// 'close-modal': !this.noCloseOnBackdrop,
109-
'fade': !this.noFade,
113+
'fade': this.fade,
110114
'show': this.visible,
111115
'd-block': this.visible || this.isTransitioning,
112116
[`modal-${this.color}`]: Boolean(this.color)
@@ -143,7 +147,7 @@ export default {
143147
},
144148
methods: {
145149
modalClick (e) {
146-
if (e.target === this.$el.firstElementChild && !this.noCloseOnBackdrop) {
150+
if (e.target === this.$el.firstElementChild && this.closeOnBackdrop) {
147151
this.hide(e)
148152
}
149153
},
@@ -153,7 +157,7 @@ export default {
153157
},
154158
toggle (newVal) {
155159
setTimeout(() => { this.visible = newVal }, 0)
156-
if (!this.noFade) {
160+
if (this.fade) {
157161
this.isTransitioning = true
158162
clearTimeout(this.timeout)
159163
this.timeout = setTimeout(() => {

src/components/Modal/tests/CModal.spec.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ const customWrapper = mount(Component, {
1111
size: 'lg',
1212
color: 'success',
1313
borderColor: 'success',
14-
noFade: false,
15-
noBackdrop: false,
16-
noCloseOnBackdrop: true,
17-
noFooter: true,
14+
fade: true,
15+
backdrop: true,
16+
closeOnBackdrop: false,
1817
addModalClasses: 'additional-modal-class',
1918
addDialogClasses: 'additional-dialog-class',
2019
addContentClasses: 'additional-content-class'
@@ -34,17 +33,17 @@ describe(ComponentName, () => {
3433
it('renders correctly', () => {
3534
expect(customWrapper.element).toMatchSnapshot()
3635
})
37-
it('hides on backdrop click', () => {
36+
it('hides on backdrop click when closeOnBackdrop prop is true', () => {
3837
const click = () => customWrapper.find('.modal').trigger('click')
3938
click()
4039
expect(customWrapper.emitted().hide).not.toBeTruthy()
4140

42-
customWrapper.setProps({ noCloseOnBackdrop: false })
41+
customWrapper.setProps({ closeOnBackdrop: true })
4342
click()
4443
expect(customWrapper.emitted().hide).toBeTruthy()
4544
})
46-
it('doesnt animate when noFade prop is set', () => {
47-
defaultWrapper.setProps({ noFade: true })
45+
it('doesnt animate when fade prop is set to false', () => {
46+
defaultWrapper.setProps({ fade: false })
4847
defaultWrapper.vm.toggle(true)
4948
expect(defaultWrapper.vm.isTransitioning).toBe(false)
5049
})

src/components/Modal/tests/__snapshots__/CModal.spec.js.snap

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,27 @@ exports[`CModal renders correctly 2`] = `
111111
CModal body
112112
</div>
113113
114-
<!---->
114+
<footer
115+
class="modal-footer"
116+
>
117+
<button
118+
class="btn btn-secondary"
119+
type="button"
120+
>
121+
122+
Cancel
123+
124+
</button>
125+
126+
<button
127+
class="btn btn-success"
128+
type="button"
129+
>
130+
131+
OK
132+
133+
</button>
134+
</footer>
115135
</div>
116136
</div>
117137
</div>

src/components/Pagination/CPagination.vue

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<nav aria-label="pagination">
33
<ul :class="computedClasses">
4-
<li v-if="!hideDoubleArrows" :class="backArrowsClasses">
4+
<li v-if="doubleArrows" :class="backArrowsClasses">
55
<CLink
66
class="page-link"
77
@click="setPage(1)"
@@ -12,7 +12,7 @@
1212
<span v-html="firstButtonHtml"></span>
1313
</CLink>
1414
</li>
15-
<li v-if="!hideArrows" :class="backArrowsClasses">
15+
<li v-if="arrows" :class="backArrowsClasses">
1616
<CLink
1717
class="page-link"
1818
@click="setPage(activePage - 1)"
@@ -53,7 +53,7 @@
5353
<span class="page-link">…</span>
5454
</li>
5555
<li
56-
v-if="!hideArrows"
56+
v-if="arrows"
5757
:class="nextArrowsClasses"
5858
>
5959
<CLink
@@ -66,7 +66,7 @@
6666
<span v-html="nextButtonHtml"></span>
6767
</CLink>
6868
</li>
69-
<li v-if="!hideDoubleArrows" :class="nextArrowsClasses">
69+
<li v-if="doubleArrows" :class="nextArrowsClasses">
7070
<CLink
7171
class="page-link"
7272
@click="setPage(pages)"
@@ -113,9 +113,18 @@
113113
type: Number,
114114
default: 5
115115
},
116-
hideDots: Boolean,
117-
hideArrows: Boolean,
118-
hideDoubleArrows: Boolean,
116+
dots: {
117+
type: Boolean,
118+
default: true
119+
},
120+
arrows: {
121+
type: Boolean,
122+
default: true
123+
},
124+
doubleArrows: {
125+
type: Boolean,
126+
default: true
127+
},
119128
firstButtonHtml: {
120129
type: String,
121130
default: '&laquo;'
@@ -169,7 +178,7 @@
169178
return `pagination pagination-${this.dims} justify-content-${this.align}`
170179
},
171180
showDots () {
172-
return !this.hideDots && this.limit > 4 && this.limit < this.pages
181+
return this.dots && this.limit > 4 && this.limit < this.pages
173182
},
174183
maxPrevItems () {
175184
return Math.floor((this.limit - 1) / 2)

src/components/Pagination/tests/CPagination.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ const customWrapper = mount(Component, {
1010
size: 'lg',
1111
align: 'center',
1212
limit: 7,
13-
hideDots: true,
14-
hideArrows: true,
15-
hideDoubleArrows: true,
13+
dots: false,
14+
arrows: false,
15+
doubleArrows: false,
1616
responsive: true
1717
}
1818
})

0 commit comments

Comments
 (0)