Skip to content

Commit

Permalink
feat(progress): [progress] 增加progress示例适配新规范额外特性
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxi-20 committed Oct 21, 2024
1 parent 85d7696 commit a04e4bc
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { ref } from 'vue'
import { Progress as TinyProgress, Button as TinyButton } from '@opentiny/vue'
import { iconMinus, iconPlus } from '@opentiny/vue-icon'
const percentage = ref(90)
const percentage = ref(45)
const IconMinus = iconMinus()
const IconPlus = iconPlus()
Expand Down
16 changes: 11 additions & 5 deletions examples/sites/demos/pc/app/progress/basic-usage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,21 @@ test('基础用法,是否可动态控制进度条', async ({ page }) => {
await expect(progress2).toHaveCSS('height', '12px')
await expect(progress1).toHaveCSS('border-radius', '2px')
await expect(progress2).toHaveCSS('border-radius', '6px')
await expect(page.getByText('90%')).toHaveCount(2)
await expect(page.getByText('45%')).toHaveCount(2)
await expect(page.getByText('努力加载中,请稍后...')).toBeVisible()

await expect(progress.nth(0)).toHaveAttribute('aria-valuenow', '90')
await expect(progress.nth(1)).toHaveAttribute('aria-valuenow', '90')
await expect(progress.nth(0)).toHaveAttribute('aria-valuenow', '45')
await expect(progress.nth(1)).toHaveAttribute('aria-valuenow', '45')
await demo.getByRole('button').nth(1).click()
await expect(progress.nth(0)).toHaveAttribute('aria-valuenow', '55')
await expect(progress.nth(1)).toHaveAttribute('aria-valuenow', '55')
await demo.getByRole('button').nth(1).click()
await demo.getByRole('button').nth(1).click()
await demo.getByRole('button').nth(1).click()
await demo.getByRole('button').nth(1).click()
await demo.getByRole('button').nth(1).click()
await demo.getByRole('button').nth(1).click()
await expect(page.getByText('努力加载中,请稍后...')).not.toBeVisible()
await expect(progress.nth(0)).toHaveAttribute('aria-valuenow', '100')
await expect(progress.nth(1)).toHaveAttribute('aria-valuenow', '100')
await demo.getByRole('button').first().click()
await expect(progress.nth(0)).toHaveAttribute('aria-valuenow', '90')
await expect(progress.nth(1)).toHaveAttribute('aria-valuenow', '90')
Expand Down
2 changes: 1 addition & 1 deletion examples/sites/demos/pc/app/progress/basic-usage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default {
},
data() {
return {
percentage: 90,
percentage: 45,
IconMinus: iconMinus(),
IconPlus: iconPlus()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import { ref } from 'vue'
import { Progress as TinyProgress, Button as TinyButton } from '@opentiny/vue'
const value = ref(20)
const customColor = ref('#409eff')
const customColor = ref('#5cb300')
// 在什么进度显示什么样的颜色
const customColors = ref([
{ color: '#f56c6c', percentage: 20 },
{ color: '#e6a23c', percentage: 40 },
{ color: '#ff8800', percentage: 40 },
{ color: '#5cb87a', percentage: 60 },
{ color: '#1989fa', percentage: 80 },
{ color: '#6f7ad3', percentage: 100 }
Expand All @@ -34,7 +34,7 @@ function add() {
// 在什么进度显示什么样的颜色
function customColorMethod(percentage) {
if (percentage < 30) {
return '#909399'
return '#f23030'
} else if (percentage < 70) {
return '#e6a23c'
} else {
Expand Down
14 changes: 7 additions & 7 deletions examples/sites/demos/pc/app/progress/custom-color.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ test('根据长度改变颜色', async ({ page }) => {
const progress3 = progress.nth(2).locator('div.tiny-progress-bar__inner')
const button = page.getByRole('button', { name: '点击增加改变颜色' })

await expect(progress1).toHaveCSS('background-color', 'rgb(64, 158, 255)')
await expect(progress2).toHaveCSS('background-color', 'rgb(144, 147, 153)')
await expect(progress3).toHaveCSS('background-color', 'rgb(230, 162, 60)')
await expect(progress1).toHaveCSS('background-color', 'rgb(92, 179, 0)')
await expect(progress2).toHaveCSS('background-color', 'rgb(242, 48, 48)')
await expect(progress3).toHaveCSS('background-color', 'rgb(255, 136, 0)')
await button.click()
await expect(progress1).toHaveCSS('background-color', 'rgb(64, 158, 255)')
await expect(progress1).toHaveCSS('background-color', 'rgb(92, 179, 0)')
await expect(progress2).toHaveCSS('background-color', 'rgb(230, 162, 60)')
await expect(progress3).toHaveCSS('background-color', 'rgb(92, 184, 122)')
await button.click()
await expect(progress1).toHaveCSS('background-color', 'rgb(64, 158, 255)')
await expect(progress1).toHaveCSS('background-color', 'rgb(92, 179, 0)')
await expect(progress2).toHaveCSS('background-color', 'rgb(230, 162, 60)')
await expect(progress3).toHaveCSS('background-color', 'rgb(25, 137, 250)')
await button.click()
await expect(progress1).toHaveCSS('background-color', 'rgb(64, 158, 255)')
await expect(progress1).toHaveCSS('background-color', 'rgb(92, 179, 0)')
await expect(progress2).toHaveCSS('background-color', 'rgb(103, 194, 58)')
await expect(progress3).toHaveCSS('background-color', 'rgb(111, 122, 211)')
await button.click()
await expect(progress1).toHaveCSS('background-color', 'rgb(64, 158, 255)')
await expect(progress1).toHaveCSS('background-color', 'rgb(92, 179, 0)')
await expect(progress2).toHaveCSS('background-color', 'rgb(103, 194, 58)')
await expect(progress3).toHaveCSS('background-color', 'rgb(111, 122, 211)')
})
6 changes: 3 additions & 3 deletions examples/sites/demos/pc/app/progress/custom-color.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export default {
data() {
return {
value: 20,
customColor: '#409eff',
customColor: '#5cb300',
// 在什么进度显示什么样的颜色
customColors: [
{ color: '#f56c6c', percentage: 20 },
{ color: '#e6a23c', percentage: 40 },
{ color: '#ff8800', percentage: 40 },
{ color: '#5cb87a', percentage: 60 },
{ color: '#1989fa', percentage: 80 },
{ color: '#6f7ad3', percentage: 100 }
Expand All @@ -41,7 +41,7 @@ export default {
// 在什么进度显示什么样的颜色
customColorMethod(percentage) {
if (percentage < 30) {
return '#909399'
return '#f23030'
} else if (percentage < 70) {
return '#e6a23c'
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import { ref } from 'vue'
import { Progress as TinyProgress, Button as TinyButton } from '@opentiny/vue'
const percentageText = ref(60)
const percentageText = ref(45)
const testInside = ref(false)
const showTest = ref(true)
Expand Down
3 changes: 2 additions & 1 deletion examples/sites/demos/pc/app/progress/format-text.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ test('文字的显隐和位置', async ({ page }) => {
const button1 = page.getByRole('button', { name: '外置文字' })
const button2 = page.getByRole('button', { name: '内置文字' })

await button2.click()
await expect(innerText).toBeVisible()
await button1.click()
await expect(outerText).toBeVisible()
await button2.click()
await expect(innerText).toBeVisible()

const text = page.getByText('自定义文字内容 60%')
const text = page.getByText('自定义文字内容 45%')

await expect(text).toBeVisible()
await page.getByRole('button', { name: '隐藏文字' }).click()
Expand Down
2 changes: 1 addition & 1 deletion examples/sites/demos/pc/app/progress/format-text.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default {
data() {
return {
showTest: true,
percentageText: 60,
percentageText: 45,
testInside: false
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<template>
<tiny-button @click="add">增加</tiny-button>
<tiny-progress type="circle" :percentage="percentage" status="exception" :width="124"></tiny-progress>
<tiny-progress type="dashboard" :percentage="percentage" status="success" :color="customColors" :width="124">
</tiny-progress>
<tiny-progress type="dashboard" :percentage="percentage" :color="customColors" :width="124"> </tiny-progress>
</template>

<script setup lang="jsx">
Expand Down
44 changes: 22 additions & 22 deletions examples/sites/demos/pc/app/progress/progress-type-circle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ test.describe('环形', () => {
const cirlePath = firstProgress.locator('.tiny-progress-circle__path')

await expect(firstProgress.locator('div.tiny-progress-circle')).toBeVisible()
await expect(circleTrack).toHaveAttribute('stroke-width', '4')
await expect(circleTrack).toHaveAttribute('stroke-width', '4.8')
await expect(circleTrack).toHaveAttribute('stroke', '#e5e9f2')
await expect(circleTrack).toHaveCSS('d', 'path("M 50 50 M 50 2 A 48 48 0 1 1 50 98 A 48 48 0 1 1 50 2")')
await expect(cirlePath).toHaveAttribute('stroke-width', '4')
await expect(circleTrack).toHaveCSS('d', 'path("M 50 50 M 50 3 A 47 47 0 1 1 50 97 A 47 47 0 1 1 50 3")')
await expect(cirlePath).toHaveAttribute('stroke-width', '4.8')
await expect(cirlePath).toHaveAttribute('stroke', '#eb171f')
await expect(cirlePath).toHaveAttribute('stroke-linecap', 'round')
await expect(cirlePath).toHaveCSS('d', 'path("M 50 50 M 50 2 A 48 48 0 1 1 50 98 A 48 48 0 1 1 50 2")')
await expect(cirlePath).toHaveCSS('d', 'path("M 50 50 M 50 3 A 47 47 0 1 1 50 97 A 47 47 0 1 1 50 3")')
})

test('是否C型圆环类型', async ({ page }) => {
Expand All @@ -30,14 +30,14 @@ test.describe('环形', () => {
await expect(lastProgress).toHaveClass(/tiny-progress--dashboard/)
await expect(lastProgress.locator('div.tiny-progress-circle')).toBeVisible()
await expect(lastProgress.locator('div.tiny-progress__text')).toBeVisible()
await expect(circleTrack).toHaveAttribute('stroke-width', '2')
await expect(circleTrack).toHaveAttribute('stroke-width', '4.8')
await expect(circleTrack).toHaveAttribute('stroke', '#e5e9f2')
await expect(circleTrack).toHaveCSS('d', 'path("M 50 50 M 50 99 A 49 49 0 1 1 50 1 A 49 49 0 1 1 50 99")')
await expect(cirlePath).toHaveAttribute('stroke-width', '2')
await expect(cirlePath).toHaveAttribute('stroke', '#f56c6c')
await expect(circleTrack).toHaveCSS('d', 'path("M 50 50 M 50 97 A 47 47 0 1 1 50 3 A 47 47 0 1 1 50 97")')
await expect(cirlePath).toHaveAttribute('stroke-width', '4.8')
await expect(cirlePath).toHaveAttribute('stroke', '#5cb87a')
await expect(cirlePath).toHaveAttribute('stroke-linecap', 'round')
await expect(cirlePath).toHaveCSS('d', 'path("M 50 50 M 50 99 A 49 49 0 1 1 50 1 A 49 49 0 1 1 50 99")')
await expect(cirlePath).toHaveCSS('stroke-dasharray', '23.0907px, 307.876px')
await expect(cirlePath).toHaveCSS('d', 'path("M 50 50 M 50 97 A 47 47 0 1 1 50 3 A 47 47 0 1 1 50 97")')
await expect(cirlePath).toHaveCSS('stroke-dasharray', '110.741px, 295.31px')
})

test('点击值增加', async ({ page }) => {
Expand All @@ -50,20 +50,20 @@ test.describe('环形', () => {
const lastProgress = page.getByRole('progressbar').last()
const cirlePath2 = lastProgress.locator('.tiny-progress-circle__path')

await expect(firstProgress).toHaveAttribute('aria-valuenow', '10')
await expect(cirlePath1).toHaveCSS('stroke-dasharray', '30.1593px, 301.593px')
await expect(lastProgress).toHaveAttribute('aria-valuenow', '10')
await expect(cirlePath2).toHaveCSS('stroke-dasharray', '23.0907px, 307.876px')
await expect(firstProgress).toHaveAttribute('aria-valuenow', '50')
await expect(cirlePath1).toHaveCSS('stroke-dasharray', '147.655px, 295.31px')
await expect(lastProgress).toHaveAttribute('aria-valuenow', '50')
await expect(cirlePath2).toHaveCSS('stroke-dasharray', '110.741px, 295.31px')
await page.getByRole('button', { name: '增加' }).click()
await expect(firstProgress).toHaveAttribute('aria-valuenow', '20')
await expect(cirlePath1).toHaveCSS('stroke-dasharray', '60.3186px, 301.593px')
await expect(lastProgress).toHaveAttribute('aria-valuenow', '20')
await expect(cirlePath2).toHaveCSS('stroke-dasharray', '46.1814px, 307.876px')
await expect(firstProgress).toHaveAttribute('aria-valuenow', '60')
await expect(cirlePath1).toHaveCSS('stroke-dasharray', '177.186px, 295.31px')
await expect(lastProgress).toHaveAttribute('aria-valuenow', '60')
await expect(cirlePath2).toHaveCSS('stroke-dasharray', '132.889px, 295.31px')

await page.getByRole('button', { name: '增加' }).click()
await expect(firstProgress).toHaveAttribute('aria-valuenow', '30')
await expect(cirlePath1).toHaveCSS('stroke-dasharray', '90.4779px, 301.593px')
await expect(lastProgress).toHaveAttribute('aria-valuenow', '30')
await expect(cirlePath2).toHaveCSS('stroke-dasharray', '69.2721px, 307.876px')
await expect(firstProgress).toHaveAttribute('aria-valuenow', '70')
await expect(cirlePath1).toHaveCSS('stroke-dasharray', '206.717px, 295.31px')
await expect(lastProgress).toHaveAttribute('aria-valuenow', '70')
await expect(cirlePath2).toHaveCSS('stroke-dasharray', '155.038px, 295.31px')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
<div>
<tiny-button @click="add">增加</tiny-button>
<tiny-progress type="circle" :percentage="percentage" status="exception" :width="124"></tiny-progress>
<tiny-progress type="dashboard" :percentage="percentage" status="success" :color="customColors" :width="124">
</tiny-progress>
<tiny-progress type="dashboard" :percentage="percentage" :color="customColors" :width="124"> </tiny-progress>
</div>
</template>

Expand Down
2 changes: 1 addition & 1 deletion packages/theme/src/progress/vars.less
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// 横向条未完成背景色
--tv-Progress-outer-bg-color: var(--tv-color-bg-gray-2, #e6e6e6);
// 横向条已完成背景色
--tv-Progress-inner-bg-color: var(--tv-color-success-bg, #5cb300);
--tv-Progress-inner-bg-color: var(--tv-color-info-bg, #1476ff);
// 横向条内层文本字号
--tv-Progress-inner-font-size: var(--tv-font-size-md, 14px);
// 横向条内层文本色
Expand Down

0 comments on commit a04e4bc

Please sign in to comment.