Skip to content

Commit 394a424

Browse files
refactor css centering
1 parent 5c33b29 commit 394a424

File tree

2 files changed

+59
-39
lines changed

2 files changed

+59
-39
lines changed

src/msgbox.vue

Lines changed: 53 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,45 @@
11
<template>
2-
<div class="msgbox" v-if="rendered" v-show="visible" transition="pop-bounce">
3-
<div class="msgbox-header" v-if="title !== ''">
4-
<div class="msgbox-title">{{ title }}</div>
5-
<!--<div class="msgbox-close d-icon icon-close" @click="handleAction('close')"></div>-->
6-
</div>
7-
<div class="msgbox-content" v-if="message !== ''">
8-
<div class="msgbox-status d-icon {{ type ? 'icon-' + type : '' }}"></div>
9-
<div class="msgbox-message"><p>{{ message }}</p></div>
10-
<div class="msgbox-input" v-show="showInput">
11-
<input type="text" v-model="inputValue" :placeholder="inputPlaceholder" />
12-
<div class="msgbox-errormsg" :style="{ visibility: !!editorErrorMessage ? 'visible' : 'hidden' }">{{editorErrorMessage}}</div>
2+
<div class="msgbox-wrapper">
3+
<div class="msgbox" v-if="rendered" v-show="visible" transition="pop-bounce" v-el:box>{{ boxHeight }}
4+
<div class="msgbox-header" v-if="title !== ''">
5+
<div class="msgbox-title">{{ title }}</div>
6+
<!--<div class="msgbox-close d-icon icon-close" @click="handleAction('close')"></div>-->
7+
</div>
8+
<div class="msgbox-content" v-if="message !== ''">
9+
<div class="msgbox-status d-icon {{ type ? 'icon-' + type : '' }}"></div>
10+
<div class="msgbox-message"><p>{{ message }}</p></div>
11+
<div class="msgbox-input" v-show="showInput">
12+
<input type="text" v-model="inputValue" :placeholder="inputPlaceholder" />
13+
<div class="msgbox-errormsg" :style="{ visibility: !!editorErrorMessage ? 'visible' : 'hidden' }">{{editorErrorMessage}}</div>
14+
</div>
15+
</div>
16+
<div class="msgbox-btns" :class="{ 'msgbox-btns-reverse': confirmButtonPosition === 'left' }">
17+
<button class="{{ cancelButtonClasses }}" v-show="showCancelButton" @click="handleAction('cancel')">{{ cancelButtonText }}</button>
18+
<button class="{{ confirmButtonClasses }}" v-show="showConfirmButton" @click="handleAction('confirm')">{{ confirmButtonText }}</button>
1319
</div>
14-
</div>
15-
<div class="msgbox-btns" :class="{ 'msgbox-btns-reverse': confirmButtonPosition === 'left' }">
16-
<button class="{{ cancelButtonClasses }}" v-show="showCancelButton" @click="handleAction('cancel')">{{ cancelButtonText }}</button>
17-
<button class="{{ confirmButtonClasses }}" v-show="showConfirmButton" @click="handleAction('confirm')">{{ confirmButtonText }}</button>
1820
</div>
1921
</div>
2022
</template>
2123

2224
<style>
25+
.msgbox-wrapper {
26+
display: flex;
27+
justify-content: center;
28+
align-items: center;
29+
top: 0;
30+
right: 0;
31+
bottom: 0;
32+
left: 0;
33+
background-color: transparent;
34+
}
35+
2336
.msgbox {
24-
position: fixed;
2537
background-color: #fff;
26-
width: 90%;
38+
width: 85%;
2739
border-radius: 3px;
2840
font-size: 16px;
2941
-webkit-user-select: none;
30-
left: 50%;
31-
top: 50%;
32-
-webkit-transform: translate(-50%, -50%);
33-
transform: translate(-50%, -50%);
42+
overflow: hidden;
3443
}
3544
3645
.msgbox-header{
@@ -165,45 +174,45 @@
165174
166175
@-webkit-keyframes pop-bounce-in {
167176
0% {
168-
-webkit-transform: translate(-50%, -50%) scale(0.8);
169-
transform: translate(-50%, -50%) scale(0.8);
177+
-webkit-transform: scale(0.8);
178+
transform: scale(0.8);
170179
}
171180
100% {
172-
-webkit-transform: translate(-50%, -50%) scale(1);
173-
transform: translate(-50%, -50%) scale(1);
181+
-webkit-transform: scale(1);
182+
transform: scale(1);
174183
}
175184
}
176185
177186
@keyframes pop-bounce-in {
178187
0% {
179-
-webkit-transform: translate(-50%, -50%) scale(0.8);
180-
transform: translate(-50%, -50%) scale(0.8);
188+
-webkit-transform: scale(0.8);
189+
transform: scale(0.8);
181190
}
182191
100% {
183-
-webkit-transform: translate(-50%, -50%) scale(1);
184-
transform: translate(-50%, -50%) scale(1);
192+
-webkit-transform: scale(1);
193+
transform: scale(1);
185194
}
186195
}
187196
188197
@-webkit-keyframes pop-bounce-out {
189198
0% {
190-
-webkit-transform: translate(-50%, -50%) scale(1);
191-
transform: translate(-50%, -50%) scale(1);
199+
-webkit-transform: scale(1);
200+
transform: scale(1);
192201
}
193202
100% {
194-
-webkit-transform: translate(-50%, -50%) scale(0.7);
195-
transform: translate(-50%, -50%) scale(0.7);
203+
-webkit-transform: scale(0.7);
204+
transform: scale(0.7);
196205
}
197206
}
198207
199208
@keyframes pop-bounce-out {
200209
0% {
201-
-webkit-transform: translate(-50%, -50%) scale(1);
202-
transform: translate(-50%, -50%) scale(1);
210+
-webkit-transform: scale(1);
211+
transform: scale(1);
203212
}
204213
100% {
205-
-webkit-transform: translate(-50%, -50%) scale(0.7);
206-
transform: translate(-50%, -50%) scale(0.7);
214+
-webkit-transform: scale(0.7);
215+
transform: scale(0.7);
207216
}
208217
}
209218
</style>
@@ -236,7 +245,7 @@
236245
return classes;
237246
},
238247
cancelButtonClasses() {
239-
var classes = 'msgbox-btn msgbox-cancel ' + this.confirmButtonClass;
248+
var classes = 'msgbox-btn msgbox-cancel ' + this.cancelButtonClass;
240249
if (this.cancelButtonHighlight) {
241250
classes += ' msgbox-cancel-highlight';
242251
}
@@ -284,6 +293,12 @@
284293
if (this.$type === 'prompt') {
285294
this.validate();
286295
}
296+
},
297+
298+
visible(val) {
299+
setTimeout(() => {
300+
this.$el.style.position = val ? 'absolute' : 'static';
301+
}, 220);
287302
}
288303
},
289304

webpack.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ options.output = {
99
path: './lib'
1010
};
1111
options.externals = {
12-
vue: 'Vue'
12+
vue: {
13+
root: 'Vue',
14+
commonjs: 'vue',
15+
commonjs2: 'vue',
16+
amd: 'vue'
17+
}
1318
};
1419
options.plugins = [new ExtractTextPlugin('vue-msgbox.css')];
1520
options.vue.loaders.css = ExtractTextPlugin.extract('style', 'css');

0 commit comments

Comments
 (0)