Use portal for modals

This commit is contained in:
Tusooa Zhu 2022-03-17 00:06:26 -04:00 committed by tusooa
parent 51ade26066
commit 39e4746f61
No known key found for this signature in database
GPG Key ID: 7B467EDE43A08224
9 changed files with 114 additions and 108 deletions

View File

@ -74,24 +74,26 @@
</button> </button>
</template> </template>
</Popover> </Popover>
<confirm-modal <portal to="modal">
:showing="showingConfirmBlock" <confirm-modal
:title="$t('user_card.block_confirm_title')" v-if="showingConfirmBlock"
:confirm-text="$t('user_card.block_confirm_accept_button')" :title="$t('user_card.block_confirm_title')"
:cancel-text="$t('user_card.block_confirm_cancel_button')" :confirm-text="$t('user_card.block_confirm_accept_button')"
@accepted="doBlockUser" :cancel-text="$t('user_card.block_confirm_cancel_button')"
@cancelled="hideConfirmBlock" @accepted="doBlockUser"
> @cancelled="hideConfirmBlock"
<i18n
path="user_card.block_confirm"
tag="span"
> >
<span <i18n
place="user" path="user_card.block_confirm"
v-text="user.screen_name_ui" tag="span"
/> >
</i18n> <span
</confirm-modal> place="user"
v-text="user.screen_name_ui"
/>
</i18n>
</confirm-modal>
</portal>
</div> </div>
</template> </template>

View File

@ -11,12 +11,7 @@ const ConfirmModal = {
components: { components: {
DialogModal DialogModal
}, },
data: {
},
props: { props: {
showing: {
type: Boolean
},
title: { title: {
type: String type: String
}, },

View File

@ -1,6 +1,5 @@
<template> <template>
<dialog-modal <dialog-modal
v-if="showing"
class="confirm-modal" class="confirm-modal"
:on-cancel="onCancel" :on-cancel="onCancel"
> >

View File

@ -76,16 +76,18 @@
</button> </button>
</div> </div>
</div> </div>
<confirm-modal <portal to="modal">
:showing="showingConfirmLogout" <confirm-modal
:title="$t('login.logout_confirm_title')" v-if="showingConfirmLogout"
:confirm-text="$t('login.logout_confirm_accept_button')" :title="$t('login.logout_confirm_title')"
:cancel-text="$t('login.logout_confirm_cancel_button')" :confirm-text="$t('login.logout_confirm_accept_button')"
@accepted="doLogout" :cancel-text="$t('login.logout_confirm_cancel_button')"
@cancelled="hideConfirmLogout" @accepted="doLogout"
> @cancelled="hideConfirmLogout"
{{ $t('login.logout_confirm') }} >
</confirm-modal> {{ $t('login.logout_confirm') }}
</confirm-modal>
</portal>
</nav> </nav>
</template> </template>
<script src="./desktop_nav.js"></script> <script src="./desktop_nav.js"></script>

View File

@ -165,16 +165,18 @@
/> />
</FALayers> </FALayers>
</span> </span>
<ConfirmModal <portal to="modal">
:showing="showingDeleteDialog" <ConfirmModal
:title="$t('status.delete_confirm_title')" v-if="showingDeleteDialog"
:cancel-text="$t('status.delete_confirm_cancel_button')" :title="$t('status.delete_confirm_title')"
:confirm-text="$t('status.delete_confirm_accept_button')" :cancel-text="$t('status.delete_confirm_cancel_button')"
@cancelled="hideDeleteStatusConfirmDialog" :confirm-text="$t('status.delete_confirm_accept_button')"
@accepted="doDeleteStatus" @cancelled="hideDeleteStatusConfirmDialog"
> @accepted="doDeleteStatus"
{{ $t('status.delete_confirm') }} >
</ConfirmModal> {{ $t('status.delete_confirm') }}
</ConfirmModal>
</portal>
</template> </template>
</Popover> </Popover>
</template> </template>

View File

@ -1,33 +1,33 @@
<template> <template>
<div> <button
<button class="btn button-default follow-button"
class="btn button-default follow-button" :class="{ toggled: isPressed }"
:class="{ toggled: isPressed }" :disabled="disabled"
:disabled="disabled" :title="title"
:title="title" @click="onClick"
@click="onClick" >
> {{ label }}
{{ label }} <portal to="modal">
</button> <confirm-modal
<confirm-modal v-if="showingConfirmUnfollow"
:showing="showingConfirmUnfollow" :title="$t('user_card.unfollow_confirm_title')"
:title="$t('user_card.unfollow_confirm_title')" :confirm-text="$t('user_card.unfollow_confirm_accept_button')"
:confirm-text="$t('user_card.unfollow_confirm_accept_button')" :cancel-text="$t('user_card.unfollow_confirm_cancel_button')"
:cancel-text="$t('user_card.unfollow_confirm_cancel_button')" @accepted="doUnfollow"
@accepted="doUnfollow" @cancelled="hideConfirmUnfollow"
@cancelled="hideConfirmUnfollow"
>
<i18n
path="user_card.unfollow_confirm"
tag="span"
> >
<span <i18n
place="user" path="user_card.unfollow_confirm"
v-text="user.screen_name_ui" tag="span"
/> >
</i18n> <span
</confirm-modal> place="user"
</div> v-text="user.screen_name_ui"
/>
</i18n>
</confirm-modal>
</portal>
</button>
</template> </template>
<script src="./follow_button.js"></script> <script src="./follow_button.js"></script>

View File

@ -88,16 +88,18 @@
ref="sideDrawer" ref="sideDrawer"
:logout="logout" :logout="logout"
/> />
<confirm-modal <portal to="modal">
:showing="showingConfirmLogout" <confirm-modal
:title="$t('login.logout_confirm_title')" v-if="showingConfirmLogout"
:confirm-text="$t('login.logout_confirm_accept_button')" :title="$t('login.logout_confirm_title')"
:cancel-text="$t('login.logout_confirm_cancel_button')" :confirm-text="$t('login.logout_confirm_accept_button')"
@accepted="doLogout" :cancel-text="$t('login.logout_confirm_cancel_button')"
@cancelled="hideConfirmLogout" @accepted="doLogout"
> @cancelled="hideConfirmLogout"
{{ $t('login.logout_confirm') }} >
</confirm-modal> {{ $t('login.logout_confirm') }}
</confirm-modal>
</portal>
</div> </div>
</template> </template>

View File

@ -59,16 +59,18 @@
> >
{{ status.repeat_num }} {{ status.repeat_num }}
</span> </span>
<confirm-modal <portal to="modal">
:showing="showingConfirmDialog" <confirm-modal
:title="$t('status.repeat_confirm_title')" v-if="showingConfirmDialog"
:confirm-text="$t('status.repeat_confirm_accept_button')" :title="$t('status.repeat_confirm_title')"
:cancel-text="$t('status.repeat_confirm_cancel_button')" :confirm-text="$t('status.repeat_confirm_accept_button')"
@accepted="doRetweet" :cancel-text="$t('status.repeat_confirm_cancel_button')"
@cancelled="hideConfirmDialog" @accepted="doRetweet"
> @cancelled="hideConfirmDialog"
{{ $t('status.repeat_confirm') }} >
</confirm-modal> {{ $t('status.repeat_confirm') }}
</confirm-modal>
</portal>
</div> </div>
</template> </template>

View File

@ -314,24 +314,26 @@
:handle-links="true" :handle-links="true"
/> />
</div> </div>
<confirm-modal <portal to="modal">
:showing="showingConfirmMute" <confirm-modal
:title="$t('user_card.mute_confirm_title')" v-if="showingConfirmMute"
:confirm-text="$t('user_card.mute_confirm_accept_button')" :title="$t('user_card.mute_confirm_title')"
:cancel-text="$t('user_card.mute_confirm_cancel_button')" :confirm-text="$t('user_card.mute_confirm_accept_button')"
@accepted="doMuteUser" :cancel-text="$t('user_card.mute_confirm_cancel_button')"
@cancelled="hideConfirmMute" @accepted="doMuteUser"
> @cancelled="hideConfirmMute"
<i18n
path="user_card.mute_confirm"
tag="span"
> >
<span <i18n
place="user" path="user_card.mute_confirm"
v-text="user.screen_name_ui" tag="span"
/> >
</i18n> <span
</confirm-modal> place="user"
v-text="user.screen_name_ui"
/>
</i18n>
</confirm-modal>
</portal>
</div> </div>
</template> </template>