Skip to content

Commit 24aa22e

Browse files
committed
Feature/Support for additional custom classes
1 parent 0f26af0 commit 24aa22e

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

Diff for: src/plugin/components/dialog-window.vue

+19-7
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
<transition :name="animation" @after-leave="animationEnded('content')" appear>
99
<div v-if="show" :class="['dg-container', {'dg-container--has-input': (isHardConfirm || isPrompt)}]" @click="closeAtOutsideClick" >
1010
<div class="dg-content-cont dg-content-cont--floating">
11-
<div class="dg-main-content" @click.stop>
11+
<div class="dg-main-content" :class="customClass.mainContent" @click.stop>
1212

13-
<div :class="['dg-content-body', {'dg-content-body--has-title': messageHasTitle}]">
13+
<div :class="['dg-content-body', customClass.body, {'dg-content-body--has-title': messageHasTitle}]">
1414
<template v-if="messageHasTitle">
1515
<h6 v-if="options.html" class="dg-title" v-html="messageTitle"></h6>
1616
<h6 v-else="" class="dg-title">{{ messageTitle }}</h6>
@@ -34,15 +34,15 @@
3434
</form>
3535
</div>
3636

37-
<div class="dg-content-footer">
37+
<div class="dg-content-footer" :class="customClass.footer">
3838

39-
<button @click="clickLeftBtn()" :is="leftBtnComponent" :loading="loading"
39+
<button @click="clickLeftBtn()" :is="leftBtnComponent" :loading="loading" :class="customClass.cancel"
4040
:enabled="leftBtnEnabled" :options="options" :focus="leftBtnFocus">
4141
<span v-if="options.html" v-html="leftBtnText"></span>
4242
<span v-else="">{{ leftBtnText }}</span>
4343
</button>
4444

45-
<button :is="rightBtnComponent" @click="clickRightBtn()" :loading="loading"
45+
<button :is="rightBtnComponent" @click="clickRightBtn()" :loading="loading" :class="customClass.ok"
4646
:enabled="rightBtnEnabled" :options="options" :focus="rightBtnFocus">
4747
<span v-if="options.html" v-html="rightBtnText"></span>
4848
<span v-else="">{{ rightBtnText }}</span>
@@ -60,7 +60,7 @@
6060
<script>
6161
import OkBtn from './ok-btn.vue'
6262
import CancelBtn from './cancel-btn.vue'
63-
import {DIALOG_TYPES, ANIMATION_TYPES, CONFIRM_TYPES} from '../js/constants'
63+
import {DIALOG_TYPES, ANIMATION_TYPES, CONFIRM_TYPES, CUSTOM_CLASS} from '../js/constants'
6464
6565
import MessageMixin from '../js/mixins/message-mixin'
6666
import ButtonMixin from '../js/mixins/btn-mixin'
@@ -72,6 +72,7 @@
7272
show: true,
7373
loading: false,
7474
closed: false,
75+
customClass: Object.assign({}, CUSTOM_CLASS),
7576
endedAnimations: []
7677
}
7778
},
@@ -115,14 +116,15 @@
115116
rightBtnComponent(){
116117
return (this.options.reverse === true) ? 'cancel-btn' : 'ok-btn'
117118
},
118-
hardConfirmHelpText() {
119+
hardConfirmHelpText(){
119120
return this.options.verificationHelp
120121
.replace(/\[\+:(\w+)]/g, (match, $1) => {
121122
return this.options[$1] || match
122123
})
123124
}
124125
},
125126
mounted () {
127+
this.setCustomClasses()
126128
this.isHardConfirm && this.$refs.inputElem.focus()
127129
},
128130
methods: {
@@ -178,6 +180,16 @@
178180
this.$emit('close', this.options.id)
179181
}
180182
183+
},
184+
setCustomClasses(){
185+
if (this.options.hasOwnProperty('customClass')) {
186+
Object.keys(this.options.customClass).forEach(prop => {
187+
if (!Object.keys(CUSTOM_CLASS).includes(prop)) {
188+
console.warn(`[WARNING]: Custom class name "${prop}" could not be found!`)
189+
}
190+
});
191+
}
192+
this.customClass = Object.assign(this.customClass, this.options.customClass);
181193
}
182194
},
183195
beforeDestroy(){

Diff for: src/plugin/js/constants.js

+17
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@ export const ANIMATION_TYPES = {
1717
BOUNCE: 'dg-bounce'
1818
}
1919

20+
export const CLASS_TYPES = {
21+
MAIN_CONTENT: 'mainContent',
22+
BODY: 'body',
23+
FOOTER: 'footer',
24+
OK: 'ok',
25+
CANCEL: 'cancel'
26+
}
27+
28+
export const CUSTOM_CLASS = {
29+
[CLASS_TYPES.MAIN_CONTENT] : '',
30+
[CLASS_TYPES.BODY] : '',
31+
[CLASS_TYPES.FOOTER] : '',
32+
[CLASS_TYPES.OK] : '',
33+
[CLASS_TYPES.CANCEL] : ''
34+
}
35+
2036
export const DEFAULT_OPTIONS = {
2137
html : false,
2238
loader : false,
@@ -29,6 +45,7 @@ export const DEFAULT_OPTIONS = {
2945
message : "Proceed with the request?",
3046
clicksCount : 3,
3147
animation : 'zoom',
48+
customClass : CUSTOM_CLASS,
3249
verification : 'continue',
3350
verificationHelp : 'Type "[+:verification]" below to confirm'
3451
}

0 commit comments

Comments
 (0)