Skip to content

Commit b02e770

Browse files
committed
feature: #152
1 parent 832ffe8 commit b02e770

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

src/components/modal/modal.vue

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
<transition :name="transitionNames[0]" @after-leave="animationFinish">
88
<div v-bind="$attrs" :class="classes" :style="mainStyles" v-show="visible" @mousedown="handleMousedown">
99
<div :class="contentClasses" ref="content" :style="contentStyles" @click="handleClickModal">
10+
<a :class="[prefixCls + '-fullscreen-icon']" :style="fullscreenIconStyles"
11+
v-if="showFullscreenIcon" @click="handleFullscreen">
12+
<slot name="fullscreen">
13+
<Icon :type="fullscreen ? 'ios-contract' : 'ios-expand'"></Icon>
14+
</slot>
15+
</a>
1016
<a :class="[prefixCls + '-close']" v-if="closable" @click="close">
1117
<slot name="close">
1218
<Icon type="ios-close"></Icon>
@@ -59,7 +65,7 @@
5965
name: 'Modal',
6066
mixins: [ Locale, ScrollbarMixins ],
6167
components: { Icon, iButton },
62-
emits: ['on-cancel', 'on-ok', 'on-hidden', 'on-visible-change', 'update:modelValue'],
68+
emits: ['on-cancel', 'on-ok', 'on-hidden', 'on-visible-change', 'on-fullscreen', 'update:modelValue', 'update:fullscreenValue'],
6369
provide () {
6470
return {
6571
ModalInstance: this
@@ -129,7 +135,11 @@
129135
return !global.$VIEWUI || global.$VIEWUI.transfer === '' ? true : global.$VIEWUI.transfer;
130136
}
131137
},
132-
fullscreen: {
138+
fullscreenValue: {
139+
type: Boolean,
140+
default: false
141+
},
142+
showFullscreenIcon: {
133143
type: Boolean,
134144
default: false
135145
},
@@ -170,6 +180,7 @@
170180
showHead: true,
171181
buttonLoading: false,
172182
visible: this.modelValue,
183+
fullscreen: this.fullscreenValue,
173184
dragData: deepCopy(dragData),
174185
modalIndex: this.handleGetModalIndex(), // for Esc close the top modal
175186
isMouseTriggerIn: false, // #5800
@@ -253,6 +264,17 @@
253264
254265
return style;
255266
},
267+
fullscreenIconStyles () {
268+
let style = {};
269+
270+
const styleRight = {
271+
right: this.closable ? '44px' : '14px'
272+
};
273+
274+
Object.assign(style, styleRight);
275+
276+
return style;
277+
},
256278
localeOkText () {
257279
if (this.okText === undefined) {
258280
return this.t('i.modal.okText');
@@ -272,6 +294,11 @@
272294
}
273295
},
274296
methods: {
297+
handleFullscreen () {
298+
this.fullscreen = !this.fullscreen;
299+
this.$emit('update:fullscreenValue', this.fullscreen);
300+
this.$emit('on-fullscreen', this.fullscreen);
301+
},
275302
close () {
276303
if (!this.beforeClose) {
277304
return this.handleClose();
@@ -473,6 +500,11 @@
473500
this.dragData = deepCopy(dragData);
474501
}
475502
},
503+
fullscreenValue (val) {
504+
if (val === this.fullscreen) return;
505+
this.fullscreen = val;
506+
this.$emit('on-fullscreen', this.fullscreen);
507+
},
476508
loading (val) {
477509
if (!val) {
478510
this.buttonLoading = false;

src/styles/components/modal.less

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@
6161
.content-header;
6262
}
6363

64+
&-fullscreen-icon {
65+
z-index: 1;
66+
font-size: 18px;
67+
position: absolute;
68+
top: 10px;
69+
overflow: hidden;
70+
cursor: pointer;
71+
color: @legend-color;
72+
transition: color @transition-time ease;
73+
&:hover {
74+
color: #444;
75+
}
76+
}
77+
6478
&-close {
6579
z-index: 1;
6680
.content-close(1px, 31px);

0 commit comments

Comments
 (0)