Skip to content
Open
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
20 changes: 20 additions & 0 deletions packages/demos/app/modal/custom-btn.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<template>
<div class="content">
<tiny-button @click="value1 = !value1" :reset-time="0">自定义底部按钮内容</tiny-button>
<tiny-modal
v-model="value1"
type="confirm"
show-footer
:confirm-content="'OK'"
:cancel-content="'你好'"
>
</tiny-modal>
</div>
</template>

<script setup lang="jsx">
import { ref } from 'vue'
import { TinyButton, TinyModal } from '@opentiny/vue-mobile'

const value1 = ref(false)
</script>
15 changes: 15 additions & 0 deletions packages/demos/app/modal/status.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,26 @@
<tiny-button @click="errorClick" :reset-time="0">错误提示图标</tiny-button>
<tiny-button @click="loadingClick" :reset-time="0">加载提示图标</tiny-button>
</div>
<div class="content">
<p>标签提示图标</p>
<tiny-button @click="value1 = !value1" :reset-time="0">点击~</tiny-button>
<tiny-modal
v-model="value1"
type="confirm"
show-footer
status="success"
>
自定义内容
</tiny-modal>
</div>
</template>

<script setup lang="jsx">
import { ref } from 'vue'
import { TinyButton, TinyModal } from '@opentiny/vue-mobile'

const value1 = ref(false)

function baseClick() {
TinyModal.message({ message: '基本提示图标', status: 'info' })
}
Expand Down
42 changes: 39 additions & 3 deletions packages/demos/app/modal/webdoc/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,26 @@ export default {
},
demoId: 'mask-closable'
},
{
name: 'confirm-content',
type: 'string',
defaultValue: "'确认'",
desc: {
'zh-CN': '自定义确认按钮内容',
'en-US': 'Customize confirmation button content'
},
demoId: 'custom-btn'
},
{
name: 'cancel-content',
type: 'string',
defaultValue: "'取消'",
desc: {
'zh-CN': '自定义取消按钮内容',
'en-US': 'Customize cancel button content'
},
demoId: 'custom-btn'
},
{
name: 'fullscreen',
type: 'boolean',
Expand Down Expand Up @@ -580,11 +600,11 @@ export default {
demoId: 'status',
name: {
'zh-CN': '模态框提示图标',
'en-US': 'button type'
'en-US': 'Modal prompt icon'
},
desc: {
'zh-CN': '<p>模态框提示图标</p>',
'en-US': '<p>button type</p>'
'zh-CN': '<p>通过<code>status</code>设置模态框提示图标</p>',
'en-US': '<p>Set the modal prompt icon through <code>status</code></p>'
},
codeFiles: ['status.vue']
},
Expand All @@ -600,6 +620,22 @@ export default {
},
codeFiles: ['title.vue']
},
{
demoId: 'custom-btn',
name: {
'zh-CN': '自定义底部按钮内容',
'en-US': 'Custom bottom button content'
},
desc: {
'zh-CN': `
通过<code>confirm-content</code>属性,修改确认按钮文字;<code>cancel-content</code>属性,修改取消按钮文字。<br>
`,
'en-US': `
Modify the confirmation button text by using the <code>confirm-content</code> property; The <code> cancer-content </code> property modifies the cancel button text. <br>
`
},
codeFiles: ['custom-btn.vue']
},
{
demoId: 'top',
name: {
Expand Down
30 changes: 26 additions & 4 deletions packages/mobile/components/modal/src/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ export default defineComponent({
render() {
let { state, scopedSlots, vSize, type, resize, animat, showHeader,_constants: constants, status } = this
let { showFooter, title, message, lockScroll, lockView, mask, t } = this
let { confirmContent, cancelContent, confirmBtnProps, cancelBtnProps } = this
let { zoomLocat, visible, contentVisible, modalTop, isMsg } = state
let defaultSlot = scopedSlots.default
let footerSlot = scopedSlots.footer
const confirmButtonText = confirmContent ?? confirmBtnProps.text ?? t('ui.button.confirm')
const cancelButtonText = cancelContent ?? cancelBtnProps.text ?? t('ui.button.cancel')

const STATUS_MAPPING_COMPINENT = {
QUESTION: iconHelpSolid(),
Expand Down Expand Up @@ -98,6 +101,23 @@ export default defineComponent({
}
},
[
status
? h(
'div',
{
class: ['tiny-mobile-modal__status-wrapper']
},
[
typeof status === 'string'
? h(STATUS_MAPPING_COMPINENT[status.toUpperCase()], {
class: [constants.STATUS_MAPPING_CLASSS[status.toUpperCase()]]
})
: h(status, {
class: ['tiny-modal__status-icon']
})
]
)
: null,
h(
'span',
{
Expand Down Expand Up @@ -170,27 +190,29 @@ export default defineComponent({
Button,
{
props: {
class: ['tiny-mobile-button', 'tiny-mobile-button--default']
type: 'secondary',
size: 'small',
},
on: {
click: this.cancelEvent
}
},
t('ui.button.cancel')
cancelButtonText
)
: null,
h(
Button,
{
props: {
type: 'primary',
class: ['tiny-mobile-button', type !== 'confirm' ? 'tiny-mobile-button__single' : '']
size: 'small',
class: [type !== 'confirm' ? 'tiny-mobile-button__single' : '']
},
on: {
click: this.confirmEvent
}
},
t('ui.button.confirm')
confirmButtonText
)
]
)
Expand Down
8 changes: 3 additions & 5 deletions packages/theme-mobile/src/modal/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -389,14 +389,12 @@

&__footer {
flex-shrink: 0;
text-align: center;
padding: 24px 32px 32px;
display: flex;
justify-content: center;

.@{button-prefix-cls} {
border-radius: 18px;
width: var(--tvm-Modal-btn-width);
height: var(--tvm-Modal-btn-height);
line-height: var(--tvm-Modal-btn-height);
margin-left: var(--tvm-Modal-btn-space);

&__single {
width: var(--tvm-Modal-single-btn-width);
Expand Down
1 change: 1 addition & 0 deletions packages/theme-mobile/src/modal/vars.less
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@
--tvm-Modal-single-btn-width: 144px;
--tvm-Modal-btn-height: 36px;
--tvm-Modal-cancel-btn-bg-color: var(--tvm-color-bg-gray-1, #f5f5f5);
--tvm-Modal-btn-space: var(--tvm-space-md);
}