Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions examples/sites/demos/apis/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,18 @@ export default {
mode: ['pc', 'mobile-first'],
pcDemo: 'basic-usage',
mfDemo: ''
},
{
name: 'round',
type: 'boolean',
defaultValue: 'false',
desc: {
'zh-CN': '是否为圆角的模式',
'en-US': 'Whether it is a circular mode'
},
Comment on lines +183 to +186
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Clarify the English description.

The English description "Whether it is a circular mode" is ambiguous. "Circular" suggests a circle shape, but round here refers to rounded corners (border-radius). The Chinese "圆角" correctly translates to "rounded corners."

Apply this diff to improve clarity:

           desc: {
             'zh-CN': '是否为圆角的模式',
-            'en-US': 'Whether it is a circular mode'
+            'en-US': 'Whether to enable rounded corners'
           },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
desc: {
'zh-CN': '是否为圆角的模式',
'en-US': 'Whether it is a circular mode'
},
desc: {
'zh-CN': '是否为圆角的模式',
'en-US': 'Whether to enable rounded corners'
},
🤖 Prompt for AI Agents
In examples/sites/demos/apis/tag.js around lines 183 to 186, the English
description "Whether it is a circular mode" is ambiguous; replace it with a
clear phrase that matches the Chinese "圆角" meaning rounded corners (e.g.,
"Whether it has rounded corners" or "Enable rounded corners"). Update the
'en-US' value to the chosen clear phrasing and keep the existing 'zh-CN' value
unchanged.

mode: ['pc'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

新特性需要添加版本信息哈

pcDemo: 'round',
mfDemo: ''
}
],
events: [
Expand Down
33 changes: 33 additions & 0 deletions examples/sites/demos/pc/app/tag/round-composition-api.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<template>
<div class="tag-round-demo">
<h4>Round 属性示例</h4>

<tiny-tag type="primary" round>圆角标签</tiny-tag>
<tiny-tag type="success" round>成功标签</tiny-tag>
<tiny-tag type="warning" round>警告标签</tiny-tag>
<tiny-tag type="danger" round>危险标签</tiny-tag>

<tiny-tag type="info" round only-icon>
<tiny-icon-heartempty />
</tiny-tag>
</div>
</template>

<script setup>
import { TinyTag } from '@opentiny/vue'
import { IconHeartempty } from '@opentiny/vue-icon'
const tinyIconHeartempty = IconHeartempty()
</script>
Comment on lines +16 to +21
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Remove unused variable or register the component properly.

The variable tinyIconHeartempty is initialized but never used. The template directly references <tiny-icon-heartempty /> without explicit component registration, which may rely on auto-registration behavior.

Consider one of these solutions:

Option 1: Remove the unused variable and import (if auto-registration works):

 <script setup>
 import { TinyTag } from '@opentiny/vue'
-import { IconHeartempty } from '@opentiny/vue-icon'
-
-const tinyIconHeartempty = IconHeartempty()
 </script>

Option 2: Register and use the component explicitly:

 <script setup>
 import { TinyTag } from '@opentiny/vue'
 import { IconHeartempty } from '@opentiny/vue-icon'
 
-const tinyIconHeartempty = IconHeartempty()
+const TinyIconHeartempty = IconHeartempty()
 </script>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<script setup>
import { TinyTag } from '@opentiny/vue'
import { IconHeartempty } from '@opentiny/vue-icon'
const tinyIconHeartempty = IconHeartempty()
</script>
<script setup>
import { TinyTag } from '@opentiny/vue'
</script>
🤖 Prompt for AI Agents
In examples/sites/demos/pc/app/tag/round-composition-api.vue around lines 16 to
21, the variable tinyIconHeartempty is created but never used while the template
expects a <tiny-icon-heartempty /> component; either remove the unused
IconHeartempty import and tinyIconHeartempty constant (if relying on
auto-registration) or explicitly register the component and use the variable
(e.g., register IconHeartempty as tiny-icon-heartempty in the component context
or expose tinyIconHeartempty for the template) so the template reference matches
a registered component.


<style scoped>
.tiny-tag {
margin-right: 12px;
margin-bottom: 12px;
}
h4 {
margin-bottom: 16px;
color: #333;
}
</style>
85 changes: 85 additions & 0 deletions examples/sites/demos/pc/app/tag/round.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { test, expect } from '@playwright/test'

test('round 属性基础测试', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).not.toBeNull())
await page.goto('tag#round-usage')

// 测试圆角标签是否存在
const roundTag = page.locator('.tiny-tag').filter({ hasText: '圆角标签' }).first()
await expect(roundTag).toHaveCount(1)

// 验证圆角标签具有圆角样式
await expect(roundTag).toHaveCSS('border-radius', '9999px')

// 测试成功标签的圆角
const successTag = page.locator('.tiny-tag').filter({ hasText: '成功标签' }).first()
await expect(successTag).toHaveCSS('border-radius', '9999px')

// 测试警告标签的圆角
const warningTag = page.locator('.tiny-tag').filter({ hasText: '警告标签' }).first()
await expect(warningTag).toHaveCSS('border-radius', '9999px')

// 测试危险标签的圆角
const dangerTag = page.locator('.tiny-tag').filter({ hasText: '危险标签' }).first()
await expect(dangerTag).toHaveCSS('border-radius', '9999px')
})

test('round 属性特殊标签测试', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).not.toBeNull())
await page.goto('tag#round-usage')

// 测试圆角图标标签
const iconTag = page.locator('.tiny-tag--only-icon').first()
await expect(iconTag).toHaveCSS('border-radius', '9999px')

// 测试圆角配置式标签
const valueTag = page.locator('.tiny-tag').filter({ hasText: '圆角配置标签' })
await expect(valueTag).toHaveCount(1)
await expect(valueTag).toHaveCSS('border-radius', '9999px')
})

test('round 属性样式验证', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).not.toBeNull())
await page.goto('tag#round-usage')

// 验证所有具有round属性的标签都具有正确的圆角样式
const roundTags = page.locator('.tiny-tag')
const count = await roundTags.count()

for (let i = 0; i < count; i++) {
const tag = roundTags.nth(i)
await expect(tag).toHaveCSS('border-radius', '9999px')
}

// 验证标签数量是否正确
expect(count).toBe(6) // 4个基础标签 + 1个图标标签 + 1个配置标签
})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Test count expectation is incorrect.

Line 55 expects 6 tags, but the demos (round.vue and round-composition-api.vue) only contain 5 tags:

  • 4 basic tags (圆角标签, 成功标签, 警告标签, 危险标签)
  • 1 icon-only tag

The comment references "1个配置标签" (1 config tag) that doesn't exist.

Update the expected count or add the missing tag:

-  // 验证标签数量是否正确
-  expect(count).toBe(6) // 4个基础标签 + 1个图标标签 + 1个配置标签
+  // 验证标签数量是否正确
+  expect(count).toBe(5) // 4个基础标签 + 1个图标标签
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test('round 属性样式验证', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).not.toBeNull())
await page.goto('tag#round-usage')
// 验证所有具有round属性的标签都具有正确的圆角样式
const roundTags = page.locator('.tiny-tag')
const count = await roundTags.count()
for (let i = 0; i < count; i++) {
const tag = roundTags.nth(i)
await expect(tag).toHaveCSS('border-radius', '9999px')
}
// 验证标签数量是否正确
expect(count).toBe(6) // 4个基础标签 + 1个图标标签 + 1个配置标签
})
test('round 属性样式验证', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).not.toBeNull())
await page.goto('tag#round-usage')
// 验证所有具有round属性的标签都具有正确的圆角样式
const roundTags = page.locator('.tiny-tag')
const count = await roundTags.count()
for (let i = 0; i < count; i++) {
const tag = roundTags.nth(i)
await expect(tag).toHaveCSS('border-radius', '9999px')
}
// 验证标签数量是否正确
expect(count).toBe(5) // 4个基础标签 + 1个图标标签
})
🤖 Prompt for AI Agents
In examples/sites/demos/pc/app/tag/round.spec.ts around lines 41 to 56, the test
asserts expect(count).toBe(6) but the demos only render 5 tags; update the test
to match the source of truth by changing the expectation to
expect(count).toBe(5) (or alternatively add the missing config tag to the round
demo files if the intention is to keep 6), and run the spec to verify it passes.


test('round 属性视觉呈现测试', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).not.toBeNull())
await page.goto('tag#round-usage')

// 测试不同类型的标签视觉呈现
const typeClasses = [
'tiny-tag--primary',
'tiny-tag--success',
'tiny-tag--warning',
'tiny-tag--danger',
'tiny-tag--info'
]

for (const typeClass of typeClasses) {
const tag = page.locator(`.tiny-tag.${typeClass}`).first()
await expect(tag).toBeVisible()

// 验证圆角样式
const borderRadius = await tag.evaluate((el) => {
return window.getComputedStyle(el).borderRadius
})
expect(borderRadius).toBe('9999px')

// 验证标签可见且具有内容
const isVisible = await tag.isVisible()
expect(isVisible).toBe(true)
}
})
39 changes: 39 additions & 0 deletions examples/sites/demos/pc/app/tag/round.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<template>
<div class="tag-round-demo">
<h4>Round 属性示例</h4>

<tiny-tag type="primary" :round="true">圆角标签</tiny-tag>
<tiny-tag type="success" :round="true">成功标签</tiny-tag>
<tiny-tag type="warning" :round="true">警告标签</tiny-tag>
<tiny-tag type="danger" :round="true">危险标签</tiny-tag>

<tiny-tag type="info" :round="true" :only-icon="true">
<template #default>
<icon-heartempty />
</template>
</tiny-tag>
</div>
</template>

<script>
import { Tag, Icon } from '@opentiny/vue'

export default {
components: {
TinyTag: Tag,
IconHeartempty: Icon.IconHeartempty
}
}
</script>

<style scoped>
.tiny-tag {
margin-right: 12px;
margin-bottom: 12px;
}

h4 {
margin-bottom: 16px;
color: #333;
}
</style>
24 changes: 24 additions & 0 deletions examples/sites/demos/pc/app/tag/webdoc/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,30 @@ export default {
},
codeFiles: ['delete.vue']
},
{
demoId: 'round',
name: {
'zh-CN': '圆角',
'en-US': 'Round'
},
desc: {
'zh-CN': '通过 <code>round</code> 设置圆角。',
'en-US': 'Set the round through <code>round</code> .'
},
codeFiles: ['round.vue'],
api: {
props: {
round: {
type: 'boolean',
defaultValue: 'false',
desc: {
'zh-CN': '是否为圆角的模式',
'en-US': 'Whether it is a round mode'
}
}
}
}
},
{
demoId: 'slot-default',
name: {
Expand Down
4 changes: 4 additions & 0 deletions packages/vue/src/tag/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export const tagProps = {
type: [String, Number],
default: null
},
round: {
type: Boolean,
default: false
},
// mobile
mini: {
type: Boolean,
Expand Down
13 changes: 10 additions & 3 deletions packages/vue/src/tag/src/pc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export default defineComponent({
'value',
'beforeDelete',
'onlyIcon',
'maxWidth'
'maxWidth',
'round'
],
setup(props, context) {
return setup({ props, context, renderless, api, h }) as unknown as ITagApi
Expand All @@ -53,7 +54,8 @@ export default defineComponent({
state,
value,
onlyIcon,
maxWidth
maxWidth,
round
} = this

let styles = {}
Expand All @@ -65,7 +67,8 @@ export default defineComponent({
effect ? `tiny-tag--${effect}` : '',
hit && 'is-hit',
disabled ? 'is-disabled' : '',
onlyIcon ? 'tiny-tag--only-icon' : ''
onlyIcon ? 'tiny-tag--only-icon' : '',
round ? 'tiny-tag--round' : ''
]

if (color) {
Expand All @@ -82,6 +85,10 @@ export default defineComponent({
styles.maxWidth = maxWidth
}

if (round) {
styles.borderRadius = '9999px'
}

const tagElement =
value || (slots.default && slots.default()) ? (
<span data-tag="tiny-tag" class={classes} style={styles} onClick={handleClick}>
Expand Down
Loading