Skip to content

Feature/Support for additional custom classes #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/docs/scss/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,24 @@ footer {
text-align: center;
}
}


.red {
color: red;
}

.green {
color: green;
}

.white {
color: white;
}

.bg-white{
background: white;
}

.bg-black {
background: black;
}
26 changes: 19 additions & 7 deletions src/plugin/components/dialog-window.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<transition :name="animation" @after-leave="animationEnded('content')" appear>
<div v-if="show" :class="['dg-container', {'dg-container--has-input': (isHardConfirm || isPrompt)}]" @click="closeAtOutsideClick" >
<div class="dg-content-cont dg-content-cont--floating">
<div class="dg-main-content" @click.stop>
<div class="dg-main-content" :class="customClass.mainContent" @click.stop>

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

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

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

<button :is="rightBtnComponent" @click="clickRightBtn()" :loading="loading"
<button :is="rightBtnComponent" @click="clickRightBtn()" :loading="loading" :class="customClass.ok"
:enabled="rightBtnEnabled" :options="options" :focus="rightBtnFocus">
<span v-if="options.html" v-html="rightBtnText"></span>
<span v-else="">{{ rightBtnText }}</span>
Expand All @@ -60,7 +60,7 @@
<script>
import OkBtn from './ok-btn.vue'
import CancelBtn from './cancel-btn.vue'
import {DIALOG_TYPES, ANIMATION_TYPES, CONFIRM_TYPES} from '../js/constants'
import {DIALOG_TYPES, ANIMATION_TYPES, CONFIRM_TYPES, CUSTOM_CLASS} from '../js/constants'

import MessageMixin from '../js/mixins/message-mixin'
import ButtonMixin from '../js/mixins/btn-mixin'
Expand All @@ -72,6 +72,7 @@
show: true,
loading: false,
closed: false,
customClass: Object.assign({}, CUSTOM_CLASS),
endedAnimations: []
}
},
Expand Down Expand Up @@ -115,14 +116,15 @@
rightBtnComponent(){
return (this.options.reverse === true) ? 'cancel-btn' : 'ok-btn'
},
hardConfirmHelpText() {
hardConfirmHelpText(){
return this.options.verificationHelp
.replace(/\[\+:(\w+)]/g, (match, $1) => {
return this.options[$1] || match
})
}
},
mounted () {
this.setCustomClasses()
this.isHardConfirm && this.$refs.inputElem.focus()
},
methods: {
Expand Down Expand Up @@ -178,6 +180,16 @@
this.$emit('close', this.options.id)
}

},
setCustomClasses(){
if (this.options.hasOwnProperty('customClass')) {
Object.keys(this.options.customClass).forEach(prop => {
if (!Object.keys(CUSTOM_CLASS).includes(prop)) {
console.warn(`[WARNING]: Custom class name "${prop}" could not be found!`)
}
});
}
this.customClass = Object.assign(this.customClass, this.options.customClass);
}
},
beforeDestroy(){
Expand Down
17 changes: 17 additions & 0 deletions src/plugin/js/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@ export const ANIMATION_TYPES = {
BOUNCE: 'dg-bounce'
}

export const CLASS_TYPES = {
MAIN_CONTENT: 'mainContent',
BODY: 'body',
FOOTER: 'footer',
OK: 'ok',
CANCEL: 'cancel'
}

export const CUSTOM_CLASS = {
[CLASS_TYPES.MAIN_CONTENT] : '',
[CLASS_TYPES.BODY] : '',
[CLASS_TYPES.FOOTER] : '',
[CLASS_TYPES.OK] : '',
[CLASS_TYPES.CANCEL] : ''
}

export const DEFAULT_OPTIONS = {
html : false,
loader : false,
Expand All @@ -29,6 +45,7 @@ export const DEFAULT_OPTIONS = {
message : "Proceed with the request?",
clicksCount : 3,
animation : 'zoom',
customClass : CUSTOM_CLASS,
verification : 'continue',
verificationHelp : 'Type "[+:verification]" below to confirm'
}