generated from thzxcx/vue3
refactor(tag): type类型
This commit is contained in:
@ -1,8 +1,8 @@
|
|||||||
<!--
|
<!--
|
||||||
* @Author: peerless_hero peerless_hero@outlook.com
|
* @Author: peerless_hero peerless_hero@outlook.com
|
||||||
* @Date: 2023-07-11 02:12:08
|
* @Date: 2023-07-11 02:12:08
|
||||||
* @LastEditors: peerless_hero peerless_hero@outlook.com
|
* @LastEditors: zhaojinfeng 121016171@qq.com
|
||||||
* @LastEditTime: 2023-07-11 03:15:44
|
* @LastEditTime: 2023-08-03 17:26:31
|
||||||
* @FilePath: \uni\packages\tag\index.vue
|
* @FilePath: \uni\packages\tag\index.vue
|
||||||
* @Description:
|
* @Description:
|
||||||
*
|
*
|
||||||
@ -15,7 +15,7 @@
|
|||||||
inline-block
|
inline-block
|
||||||
min-w-128rpx
|
min-w-128rpx
|
||||||
h-48rpx
|
h-48rpx
|
||||||
fs-24
|
text-24rpx
|
||||||
font-500
|
font-500
|
||||||
leh-48
|
leh-48
|
||||||
border-2rpx
|
border-2rpx
|
||||||
@ -32,9 +32,11 @@ import { computed } from 'vue'
|
|||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
/** 类型 */
|
/** 类型 */
|
||||||
type?: 'default' | 'error' | 'warning'
|
type?: 'default' | 'primary' | 'danger' | 'warning' | 'success' | 'info'
|
||||||
/** 显示文本 */
|
/** 显示文本 */
|
||||||
text?: string
|
text?: string
|
||||||
|
/** 纯文字,无背景色 */
|
||||||
|
plain?: boolean
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
type: 'default',
|
type: 'default',
|
||||||
@ -42,13 +44,18 @@ const props = withDefaults(
|
|||||||
)
|
)
|
||||||
|
|
||||||
const className = computed(() => {
|
const className = computed(() => {
|
||||||
|
const bg = props.plain ? '' : ' bgc'
|
||||||
switch (props.type) {
|
switch (props.type) {
|
||||||
case 'error':
|
case 'danger':
|
||||||
return 'th-tag-error'
|
return `th-tag-danger${bg}`
|
||||||
|
case 'primary':
|
||||||
|
return `th-tag-primary${bg}`
|
||||||
case 'warning':
|
case 'warning':
|
||||||
return 'th-tag-warning'
|
return `th-tag-warning${bg}`
|
||||||
|
case 'success':
|
||||||
|
return `th-tag-success${bg}`
|
||||||
default:
|
default:
|
||||||
return 'th-tag-default'
|
return `th-tag-default${bg}`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@ -57,21 +64,42 @@ const className = computed(() => {
|
|||||||
.th-tag {
|
.th-tag {
|
||||||
|
|
||||||
&.th-tag-default {
|
&.th-tag-default {
|
||||||
background-color: #f9f9f9;
|
|
||||||
border-color: #cccccc;
|
border-color: #cccccc;
|
||||||
color: #393939;
|
color: #393939;
|
||||||
|
&.bgc {
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.th-tag-error {
|
&.th-tag-danger {
|
||||||
background-color: #fef0f0;
|
|
||||||
border-color: #fbc7c7;
|
border-color: #fbc7c7;
|
||||||
color: #e43d33;
|
color: #e43d33;
|
||||||
|
&.bgc{
|
||||||
|
background-color: #fef0f0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.th-tag-warning {
|
&.th-tag-warning {
|
||||||
background-color: #fff6e8;
|
|
||||||
border-color: #f6ddb8;
|
border-color: #f6ddb8;
|
||||||
color: #f3a73f;
|
color: #f3a73f;
|
||||||
|
&.bgc{
|
||||||
|
background-color: #fff6e8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.th-tag-success {
|
||||||
|
border-color: #c8eab7;
|
||||||
|
color: #18bc37;
|
||||||
|
&.bgc {
|
||||||
|
background-color: #f0f9eb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&.th-tag-primary {
|
||||||
|
border-color: #bcddff;
|
||||||
|
color: #2979ff;
|
||||||
|
&.bgc{
|
||||||
|
background-color: #f2f7ff;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* @Author: peerless_hero peerless_hero@outlook.com
|
* @Author: peerless_hero peerless_hero@outlook.com
|
||||||
* @Date: 2023-07-11 02:12:08
|
* @Date: 2023-07-11 02:12:08
|
||||||
* @LastEditors: peerless_hero peerless_hero@outlook.com
|
* @LastEditors: zhaojinfeng 121016171@qq.com
|
||||||
* @LastEditTime: 2023-07-11 03:02:55
|
* @LastEditTime: 2023-08-03 17:29:30
|
||||||
* @FilePath: \uni\stories\Tag.stories.ts
|
* @FilePath: \uni\stories\Tag.stories.ts
|
||||||
* @Description:
|
* @Description:
|
||||||
*
|
*
|
||||||
@ -16,9 +16,10 @@ const meta = {
|
|||||||
args: {
|
args: {
|
||||||
text: '默认',
|
text: '默认',
|
||||||
type: 'default',
|
type: 'default',
|
||||||
|
plain: false,
|
||||||
},
|
},
|
||||||
argTypes: {
|
argTypes: {
|
||||||
type: { control: 'select', options: ['default', 'warning', 'error'] },
|
type: { control: 'select', options: ['default', 'primary', 'danger', 'warning', 'success', 'info'] },
|
||||||
},
|
},
|
||||||
tags: ['autodocs'],
|
tags: ['autodocs'],
|
||||||
} satisfies Meta<typeof ThTag>
|
} satisfies Meta<typeof ThTag>
|
||||||
@ -33,6 +34,13 @@ export const Default: Story = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const Primary: Story = {
|
||||||
|
args: {
|
||||||
|
text: '主要',
|
||||||
|
type: 'primary',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
export const Warning: Story = {
|
export const Warning: Story = {
|
||||||
args: {
|
args: {
|
||||||
text: '警告',
|
text: '警告',
|
||||||
@ -43,7 +51,7 @@ export const Warning: Story = {
|
|||||||
export const ErrorType: Story = {
|
export const ErrorType: Story = {
|
||||||
name: 'Error',
|
name: 'Error',
|
||||||
args: {
|
args: {
|
||||||
text: '错误',
|
text: '危险',
|
||||||
type: 'error',
|
type: 'danger',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user