Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(modal): [modal]optimize modal demo #1437

Merged
merged 3 commits into from
Feb 28, 2024
Merged
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
2 changes: 1 addition & 1 deletion examples/sites/demos/pc/app/modal/basic-usage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ test('基本用法', async ({ page }) => {
await page.getByRole('button', { name: /确认提示框/ }).click()
await page.getByRole('button', { name: /取消/ }).click()
await expect(confirm).not.toBeVisible()
await page.getByRole('button', { name: /确认提示框/ }).click()
await page.getByRole('button', { name: /支持传入 jsx 提示框/ }).click()
await page.locator('.tiny-modal__close-btn').click()
await expect(confirm).not.toBeVisible()
})
3 changes: 1 addition & 2 deletions examples/sites/demos/pc/app/modal/duration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ test('自动关闭延时', async ({ page }) => {

await page.getByRole('button', { name: /5000ms/ }).click()
await expect(modal).toBeVisible()
await page.waitForTimeout(5200)
const visible3 = await modal.isVisible()
expect(visible3).toEqual(false)
expect(visible3).toEqual(true)
})
16 changes: 0 additions & 16 deletions examples/sites/demos/pc/app/modal/min-height-composition-api.vue

This file was deleted.

21 changes: 0 additions & 21 deletions examples/sites/demos/pc/app/modal/min-height.spec.ts

This file was deleted.

23 changes: 0 additions & 23 deletions examples/sites/demos/pc/app/modal/min-height.vue

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<tiny-button @click="btnClick" :reset-time="0">提示框最小宽度为700</tiny-button>
<tiny-button @click="btnClick" :reset-time="0">最小宽高度</tiny-button>
</template>

<script setup>
Expand All @@ -10,7 +10,9 @@ function btnClick() {
message: '提示框拖动最小宽度为700',
resize: true,
width: 800,
minWidth: 700
height: 400,
minWidth: 700,
minHeight: 300
})
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { test, expect } from '@playwright/test'

test('调整窗口后显示的最小宽度', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('modal#min-width')
await page.goto('modal#min-width-height')

await page.getByRole('button', { name: '提示框最小宽度为700' }).click()
await page.getByRole('button', { name: '最小宽高度' }).click()
const modal = page.locator('.tiny-modal.active .tiny-modal__box')
// 获取弹窗位置
const { x, y } = await modal.boundingBox()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<tiny-button @click="btnClick" :reset-time="0">提示框最小宽度为700</tiny-button>
<tiny-button @click="btnClick" :reset-time="0">最小宽高度</tiny-button>
</template>

<script>
Expand All @@ -15,7 +15,9 @@ export default {
message: '提示框拖动最小宽度为700',
resize: true,
width: 800,
minWidth: 700
height: 400,
minWidth: 700,
minHeight: 300
})
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<template>
<tiny-button @click="btnClick" :reset-time="0">控制显示头部及底部</tiny-button>
</template>

<script setup>
import { Button as TinyButton, Modal } from '@opentiny/vue'

function btnClick() {
Modal.alert({ message: '控制显示头部及底部', showHeader: false, showFooter: true })
}
</script>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { test, expect } from '@playwright/test'

test('不显示头部', async ({ page }) => {
test('控制显示头部及底部', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('modal#showHeader')
await page.goto('modal#show-header-footer')

const modal = page.locator('.tiny-modal.active')
await page.getByRole('button', { name: '不显示头部' }).click()
await page.getByRole('button', { name: '控制显示头部及底部' }).click()
await expect(modal.locator('.tiny-modal__header')).not.toBeVisible()
})
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<tiny-button @click="btnClick" :reset-time="0">不显示底部</tiny-button>
<tiny-button @click="btnClick" :reset-time="0">控制显示头部及底部</tiny-button>
</template>

<script>
Expand All @@ -11,7 +11,7 @@ export default {
},
methods: {
btnClick() {
Modal.alert({ message: '不显示底部', showFooter: false })
Modal.alert({ message: '控制显示头部及底部', showHeader: false, showFooter: true })
}
}
}
Expand Down
11 changes: 0 additions & 11 deletions examples/sites/demos/pc/app/modal/showFooter-composition-api.vue

This file was deleted.

10 changes: 0 additions & 10 deletions examples/sites/demos/pc/app/modal/showFooter.spec.ts

This file was deleted.

11 changes: 0 additions & 11 deletions examples/sites/demos/pc/app/modal/showHeader-composition-api.vue

This file was deleted.

18 changes: 0 additions & 18 deletions examples/sites/demos/pc/app/modal/showHeader.vue

This file was deleted.

48 changes: 12 additions & 36 deletions examples/sites/demos/pc/app/modal/webdoc/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,56 +161,32 @@ export default {
codeFiles: ['resize.vue']
},
{
demoId: 'min-width',
demoId: 'min-width-height',
name: {
'zh-CN': '调整窗口后的最小宽度',
'en-US': 'The Minimum Width Of The Window Displayed After Adjusting Its Size'
'zh-CN': '调整窗口后的最小宽高度',
'en-US': 'Minimum width and height after adjusting the window'
},
desc: {
'zh-CN':
'<p>可通过<code>resize</code>属性设置可拖拽属性为<code>true</code>后,<code>min-width</code>属性设置拖拽后窗口的最小宽度。</p>',
'<p>可通过<code>resize</code>属性设置可拖拽属性为<code>true</code>后,<code>min-height</code>属性设置拖拽后窗口的最小高度,<code>min-width</code>属性设置拖拽后窗口的最小宽度。</p>',
'en-US':
'<p>By setting the<code>resize</code>drag property to<code>true</code>, the minimum width of the window after dragging can be set through the<code>min-width</code>property.</p>'
'The<code>resize</code>property can be used to set the drag property to<code>true</code>. The<code>min-height</code>property sets the minimum height of the window after dragging, and the<code>min-width</code>property sets the minimum width of the window after dragging.'
},
codeFiles: ['min-width.vue']
codeFiles: ['min-width-height.vue']
},
{
demoId: 'min-height',
demoId: 'show-header-footer',
name: {
'zh-CN': '调整窗口后的最小高度',
'en-US': 'The Minimum Height Displayed By The Window After Adjusting Its Size'
'zh-CN': '控制显示头部及底部',
'en-US': 'Do Not Display Header and Bottom'
},
desc: {
'zh-CN':
'<p>可通过<code>resize</code>属性设置可拖拽属性为<code>true</code>后,<code>min-height</code>属性设置拖拽后窗口的最小高度。</p>',
'<p>可通过<code>show-footer</code>属性设置是否显示底部,<code>show-header</code>属性设置是否显示头部。</p>',
'en-US':
'<p>By setting the<code>resize</code>drag property to<code>true</code>, the minimum height of the window after dragging can be set through the<code>min-height</code>property.</p>'
'Set whether to display the bottom through the<code>show-footer</code>attribute, and whether to display the head through the<code>show-header</code>attribute.'
},
codeFiles: ['min-height.vue']
},
{
demoId: 'showFooter',
name: {
'zh-CN': '不显示底部',
'en-US': 'Do Not Display Bottom'
},
desc: {
'zh-CN': '<p>可通过<code>show-footer</code>属性设置是否显示底部。</p>',
'en-US': '<p>Set whether to display the bottom through<code>show-root</code>.</p>'
},
codeFiles: ['showFooter.vue']
},
{
demoId: 'showHeader',
name: {
'zh-CN': '不显示头部',
'en-US': 'Do Not Display The Head'
},
desc: {
'zh-CN': '<p>可通过<code>show-header</code>属性设置是否显示头部。</p>',
'en-US': '<p>Set whether to display the header through<code>show-header</code>.</p>'
},
codeFiles: ['showHeader.vue']
codeFiles: ['show-header-footer.vue']
},
{
demoId: 'status',
Expand Down
Loading