Skip to content

Commit a1fc5d3

Browse files
author
grinmax
committed
2 parents eaaf9bc + 31a4fac commit a1fc5d3

File tree

2 files changed

+48
-21
lines changed

2 files changed

+48
-21
lines changed

src/App.vue

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<div class="buttons">
2323
<button @click="maxButtons3()">Количество кнопок 3</button>
2424
<button @click="maxButtons5()">Количество кнопок 5</button>
25+
<button @click="buttonsStyle1()">Вид кнопок 1</button>
2526
</div>
2627
<div class="spinner">
2728
<button @click="spinnerShow()">Показать спиннер</button>
@@ -84,7 +85,21 @@ export default {
8485
],
8586
PaginationControlSettings: {
8687
buttonsSettings: {
87-
maxButtons: 5
88+
maxButtons: 5,
89+
allPageButtonsStyle: {
90+
'background': '',
91+
'borderColor': '',
92+
'color': '',
93+
'backgroundHover': '',
94+
'borderColorHover': '',
95+
'colorHover': '',
96+
'fontFamily': ''
97+
},
98+
currentPageButtonStyle: {
99+
'backgroundActive': '',
100+
'borderColorActive': '',
101+
'colorActive': ''
102+
}
88103
},
89104
arrowsSettings: {
90105
hideArrows: false,
@@ -119,6 +134,11 @@ export default {
119134
maxButtons5: function (e) {
120135
this.settings.PaginationControlSettings.buttonsSettings.maxButtons = 5
121136
},
137+
buttonsStyle1: function (e) {
138+
console.log(this.settings.PaginationControlSettings.buttonsSettings.allPageButtonsStyle.background)
139+
this.settings.PaginationControlSettings.buttonsSettings.allPageButtonsStyle.background = '#000'
140+
this.settings.PaginationControlSettings.buttonsSettings.allPageButtonsStyle.borderColor = '#000'
141+
},
122142
arrowShow: function (e) {
123143
this.settings.PaginationControlSettings.arrowsSettings.hideArrows = false
124144
},

src/components/PaginationControl.vue

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -286,33 +286,40 @@ export default {
286286
}
287287
}
288288
}
289+
},
290+
rootColor: function () {
291+
let root = document.querySelector(':root')
292+
if (this.def.buttonsSettings.controlStyle === 'square') {
293+
root.style.setProperty('--controlStyle', '0')
294+
} else if (this.def.buttonsSettings.controlStyle === 'circle') {
295+
root.style.setProperty('--controlStyle', '50%')
296+
} else {
297+
root.style.setProperty('--controlStyle', '4px')
298+
}
299+
root.style.setProperty('--pageButtonsBackground', this.def.buttonsSettings.allPageButtonsStyle.background)
300+
root.style.setProperty('--pageButtonsBorderColor', this.def.buttonsSettings.allPageButtonsStyle.borderColor)
301+
root.style.setProperty('--pageButtonsColor', this.def.buttonsSettings.allPageButtonsStyle.color)
302+
root.style.setProperty('--pageButtonsFontFamily', this.def.buttonsSettings.allPageButtonsStyle.fontFamily)
303+
root.style.setProperty('--pageButtonsBackgroundHover', this.def.buttonsSettings.allPageButtonsStyle.backgroundHover)
304+
root.style.setProperty('--pageButtonsBorderColorHover', this.def.buttonsSettings.allPageButtonsStyle.borderColorHover)
305+
root.style.setProperty('--pageButtonsColorHover', this.def.buttonsSettings.allPageButtonsStyle.colorHover)
306+
root.style.setProperty('--pageButtonBackgroundActive', this.def.buttonsSettings.currentPageButtonStyle.backgroundActive)
307+
root.style.setProperty('--pageButtonBorderColorActive', this.def.buttonsSettings.currentPageButtonStyle.borderColorActive)
308+
root.style.setProperty('--pageButtonColorActive', this.def.buttonsSettings.currentPageButtonStyle.colorActive)
309+
root.style.setProperty('--controlDotsColor', this.def.dotsSettings.controlDotsColor)
310+
root.style.setProperty('--arrowStyleColorHover', this.def.arrowsSettings.arrowStyleColorHover)
289311
}
290312
},
291313
beforeMount () {
292314
document.addEventListener('keydown', this.keydown)
293-
console.log(this.def.pageStarted)
294315
this.curIndex = this.def.pageStarted - 1
295316
this.$set(this.settings.array_data[this.curIndex], 'active', true)
296-
let root = document.querySelector(':root')
297-
if (this.def.buttonsSettings.controlStyle === 'square') {
298-
root.style.setProperty('--controlStyle', '0')
299-
} else if (this.def.buttonsSettings.controlStyle === 'circle') {
300-
root.style.setProperty('--controlStyle', '50%')
301-
} else {
302-
root.style.setProperty('--controlStyle', '4px')
317+
this.rootColor()
318+
},
319+
watch: {
320+
'def': function (oldVal, newVal) {
321+
this.rootColor()
303322
}
304-
root.style.setProperty('--pageButtonsBackground', this.def.buttonsSettings.allPageButtonsStyle.background)
305-
root.style.setProperty('--pageButtonsBorderColor', this.def.buttonsSettings.allPageButtonsStyle.borderColor)
306-
root.style.setProperty('--pageButtonsColor', this.def.buttonsSettings.allPageButtonsStyle.color)
307-
root.style.setProperty('--pageButtonsFontFamily', this.def.buttonsSettings.allPageButtonsStyle.fontFamily)
308-
root.style.setProperty('--pageButtonsBackgroundHover', this.def.buttonsSettings.allPageButtonsStyle.backgroundHover)
309-
root.style.setProperty('--pageButtonsBorderColorHover', this.def.buttonsSettings.allPageButtonsStyle.borderColorHover)
310-
root.style.setProperty('--pageButtonsColorHover', this.def.buttonsSettings.allPageButtonsStyle.colorHover)
311-
root.style.setProperty('--pageButtonBackgroundActive', this.def.buttonsSettings.currentPageButtonStyle.backgroundActive)
312-
root.style.setProperty('--pageButtonBorderColorActive', this.def.buttonsSettings.currentPageButtonStyle.borderColorActive)
313-
root.style.setProperty('--pageButtonColorActive', this.def.buttonsSettings.currentPageButtonStyle.colorActive)
314-
root.style.setProperty('--controlDotsColor', this.def.dotsSettings.controlDotsColor)
315-
root.style.setProperty('--arrowStyleColorHover', this.def.arrowsSettings.arrowStyleColorHover)
316323
}
317324
}
318325
</script>

0 commit comments

Comments
 (0)