wip
This commit is contained in:
parent
cb965feab4
commit
32c4b079ba
|
@ -1,10 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="mk-dialog" :class="{ iconOnly }" :style="{ pointerEvents: closing ? 'none' : 'auto' }">
|
<x-modal ref="modal" @closed="$store.commit('removeDialog', id)" @click="onBgClick" :showing="showing">
|
||||||
<transition :name="$store.state.device.animation ? 'bg-fade' : ''" appear>
|
<div class="mk-dialog" :class="{ iconOnly }">
|
||||||
<div class="bg _modalBg" @click="onBgClick" v-if="!closing"></div>
|
|
||||||
</transition>
|
|
||||||
<transition :name="$store.state.device.animation ? 'dialog' : ''" appear @after-leave="$store.commit('removeDialog', id)">
|
|
||||||
<div class="main" v-if="!closing">
|
|
||||||
<template v-if="type == 'signin'">
|
<template v-if="type == 'signin'">
|
||||||
<mk-signin/>
|
<mk-signin/>
|
||||||
</template>
|
</template>
|
||||||
|
@ -44,8 +40,7 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</x-modal>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
@ -57,9 +52,11 @@ import MkInput from './ui/input.vue';
|
||||||
import MkSelect from './ui/select.vue';
|
import MkSelect from './ui/select.vue';
|
||||||
import MkSignin from './signin.vue';
|
import MkSignin from './signin.vue';
|
||||||
import parseAcct from '../../misc/acct/parse';
|
import parseAcct from '../../misc/acct/parse';
|
||||||
|
import XModal from './modal.vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
|
XModal,
|
||||||
MkButton,
|
MkButton,
|
||||||
MkInput,
|
MkInput,
|
||||||
MkSelect,
|
MkSelect,
|
||||||
|
@ -122,7 +119,7 @@ export default defineComponent({
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
closing: false,
|
showing: true,
|
||||||
inputValue: this.input && this.input.default ? this.input.default : null,
|
inputValue: this.input && this.input.default ? this.input.default : null,
|
||||||
userInputValue: null,
|
userInputValue: null,
|
||||||
selectedValue: this.select ? this.select.default ? this.select.default : this.select.items ? this.select.items[0].value : this.select.groupedItems[0].items[0].value : null,
|
selectedValue: this.select ? this.select.default ? this.select.default : this.select.items ? this.select.items[0].value : this.select.groupedItems[0].items[0].value : null,
|
||||||
|
@ -161,7 +158,7 @@ export default defineComponent({
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
done(canceled, result?) {
|
done(canceled, result?) {
|
||||||
this.closing = true;
|
this.showing = false;
|
||||||
this.$store.commit('dialogDone', { id: this.id, result: { canceled, result } });
|
this.$store.commit('dialogDone', { id: this.id, result: { canceled, result } });
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -211,40 +208,7 @@ export default defineComponent({
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.dialog-enter-active, .dialog-leave-active {
|
|
||||||
transition: opacity 0.3s, transform 0.3s !important;
|
|
||||||
}
|
|
||||||
.dialog-enter-from, .dialog-leave-to {
|
|
||||||
opacity: 0;
|
|
||||||
transform: scale(0.9);
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bg-fade-enter-active, .bg-fade-leave-active {
|
|
||||||
transition: opacity 0.3s !important;
|
|
||||||
}
|
|
||||||
.bg-fade-enter-from, .bg-fade-leave-to {
|
|
||||||
opacity: 0;
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mk-dialog {
|
.mk-dialog {
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
position: fixed;
|
|
||||||
z-index: 30000;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
|
|
||||||
&.iconOnly > .main {
|
|
||||||
min-width: 0;
|
|
||||||
width: initial;
|
|
||||||
}
|
|
||||||
|
|
||||||
> .main {
|
|
||||||
display: block;
|
display: block;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
|
@ -257,6 +221,11 @@ export default defineComponent({
|
||||||
background: var(--panel);
|
background: var(--panel);
|
||||||
border-radius: var(--radius);
|
border-radius: var(--radius);
|
||||||
|
|
||||||
|
&.iconOnly {
|
||||||
|
min-width: 0;
|
||||||
|
width: initial;
|
||||||
|
}
|
||||||
|
|
||||||
> .icon {
|
> .icon {
|
||||||
font-size: 32px;
|
font-size: 32px;
|
||||||
|
|
||||||
|
@ -303,6 +272,5 @@ export default defineComponent({
|
||||||
margin: 0 8px;
|
margin: 0 8px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="mk-modal" v-hotkey.global="keymap">
|
<div class="mk-modal" v-hotkey.global="keymap" :style="{ pointerEvents: showing ? 'auto' : 'none' }">
|
||||||
<transition :name="$store.state.device.animation ? 'bg-fade' : ''" appear>
|
<transition :name="$store.state.device.animation ? 'bg-fade' : ''" appear>
|
||||||
<div class="bg _modalBg" ref="bg" v-if="show" @click="canClose ? close() : () => {}"></div>
|
<div class="bg _modalBg" ref="bg" v-if="showing" @click="$emit('click')"></div>
|
||||||
</transition>
|
</transition>
|
||||||
<transition :name="$store.state.device.animation ? 'modal' : ''" appear @after-leave="() => { $emit('closed'); destroyDom(); }">
|
<transition :name="$store.state.device.animation ? 'modal' : ''" appear @after-leave="$emit('closed')">
|
||||||
<div class="content" ref="content" v-if="show" @click.self="canClose ? close() : () => {}"><slot></slot></div>
|
<div class="content" ref="content" v-if="showing" @click.self="$emit('click')"><slot></slot></div>
|
||||||
</transition>
|
</transition>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -13,32 +13,25 @@
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
|
emits: ['click', 'esc'],
|
||||||
props: {
|
props: {
|
||||||
|
showing: {
|
||||||
|
type: Boolean,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
canClose: {
|
canClose: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: false,
|
required: false,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
show: true,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
keymap(): any {
|
keymap(): any {
|
||||||
return {
|
return {
|
||||||
'esc': this.close,
|
'esc': () => this.$emit('esc'),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
|
||||||
close() {
|
|
||||||
this.show = false;
|
|
||||||
(this.$refs.bg as any).style.pointerEvents = 'none';
|
|
||||||
(this.$refs.content as any).style.pointerEvents = 'none';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -46,7 +39,8 @@ export default defineComponent({
|
||||||
.modal-enter-active, .modal-leave-active {
|
.modal-enter-active, .modal-leave-active {
|
||||||
transition: opacity 0.3s, transform 0.3s !important;
|
transition: opacity 0.3s, transform 0.3s !important;
|
||||||
}
|
}
|
||||||
.modal-enter, .modal-leave-to {
|
.modal-enter-from, .modal-leave-to {
|
||||||
|
pointer-events: none;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: scale(0.9);
|
transform: scale(0.9);
|
||||||
}
|
}
|
||||||
|
@ -54,7 +48,7 @@ export default defineComponent({
|
||||||
.bg-fade-enter-active, .bg-fade-leave-active {
|
.bg-fade-enter-active, .bg-fade-leave-active {
|
||||||
transition: opacity 0.3s !important;
|
transition: opacity 0.3s !important;
|
||||||
}
|
}
|
||||||
.bg-fade-enter, .bg-fade-leave-to {
|
.bg-fade-enter-from, .bg-fade-leave-to {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,18 +67,9 @@ export default defineComponent({
|
||||||
max-width: calc(100% - 16px);
|
max-width: calc(100% - 16px);
|
||||||
max-height: calc(100% - 16px);
|
max-height: calc(100% - 16px);
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
margin: auto;
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
::v-deep > * {
|
align-items: center;
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
margin: auto;
|
|
||||||
max-height: 100%;
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<x-modal ref="modal" @closed="() => { $emit('closed'); destroyDom(); }" :can-close="canClose">
|
<x-modal ref="modal" @closed="$emit('closed')" :can-close="canClose">
|
||||||
<div class="ebkgoccj" :class="{ noPadding }" @keydown="onKeydown" :style="{ width: `${width}px`, height: `${height}px` }">
|
<div class="ebkgoccj" :class="{ noPadding }" @keydown="onKeydown" :style="{ width: `${width}px`, height: `${height}px` }">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<button class="_button" v-if="withOkButton" @click="close()"><fa :icon="faTimes"/></button>
|
<button class="_button" v-if="withOkButton" @click="close()"><fa :icon="faTimes"/></button>
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
<mk-switch v-model:value="dialogCancel">
|
<mk-switch v-model:value="dialogCancel">
|
||||||
<span>With cancel button</span>
|
<span>With cancel button</span>
|
||||||
</mk-switch>
|
</mk-switch>
|
||||||
|
<mk-switch v-model:value="dialogCancelByBgClick">
|
||||||
|
<span>Can cancel by modal bg click</span>
|
||||||
|
</mk-switch>
|
||||||
<mk-switch v-model:value="dialogInput">
|
<mk-switch v-model:value="dialogInput">
|
||||||
<span>With input field</span>
|
<span>With input field</span>
|
||||||
</mk-switch>
|
</mk-switch>
|
||||||
|
@ -51,6 +54,7 @@ export default defineComponent({
|
||||||
dialogTitle: 'Hello',
|
dialogTitle: 'Hello',
|
||||||
dialogBody: 'World!',
|
dialogBody: 'World!',
|
||||||
dialogCancel: false,
|
dialogCancel: false,
|
||||||
|
dialogCancelByBgClick: true,
|
||||||
dialogInput: false,
|
dialogInput: false,
|
||||||
dialogResult: null,
|
dialogResult: null,
|
||||||
faExclamationTriangle
|
faExclamationTriangle
|
||||||
|
@ -59,10 +63,12 @@ export default defineComponent({
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
async showDialog() {
|
async showDialog() {
|
||||||
|
this.dialogResult = null;
|
||||||
this.dialogResult = await this.$store.dispatch('showDialog', {
|
this.dialogResult = await this.$store.dispatch('showDialog', {
|
||||||
title: this.dialogTitle,
|
title: this.dialogTitle,
|
||||||
text: this.dialogBody,
|
text: this.dialogBody,
|
||||||
showCancelButton: this.dialogCancel,
|
showCancelButton: this.dialogCancel,
|
||||||
|
cancelableByBgClick: this.dialogCancelByBgClick,
|
||||||
input: this.dialogInput ? {} : null
|
input: this.dialogInput ? {} : null
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue