feat(tag): refresh ui

Signed-off-by: jacknan <zhumaonan@aliyun.com>
This commit is contained in:
jacknan 2024-03-14 19:48:11 +08:00
parent a70d32573b
commit 0a29004ee8
7 changed files with 73 additions and 4 deletions

View File

@ -0,0 +1,30 @@
<template>
<div class="tiny-tag-demo">
<tiny-tag color="default" text="" type="round" cycleColor="#ff2956"> 默认 </tiny-tag>
<tiny-tag color="default" text="红色" type="round" />
<tiny-tag color="default" text="蓝色" type="round"> </tiny-tag>
<tiny-tag color="default" text="黄色" type="round"> </tiny-tag>
<tiny-tag color="default" text="绿色" type="round"> </tiny-tag>
</div>
</template>
<script>
import { Tag } from '@opentiny/vue'
export default {
components: {
TinyTag: Tag
}
}
</script>
<style>
.tiny-tag-demo {
padding: 10px;
}
.tiny-mobile-tag {
margin-right: 10px;
margin-bottom: 10px;
}
</style>

View File

@ -49,6 +49,18 @@ export default {
'en-US': 'Mini'
},
codeFiles: ['mini.vue']
},
{
demoId: 'style',
name: {
'zh-CN': '样式',
'en-US': 'style'
},
desc: {
'zh-CN': '样式',
'en-US': 'style'
},
codeFiles: ['style.vue']
}
]
}

View File

@ -26,7 +26,8 @@ export const renderless = (
mini: props.mini,
color: props.color,
text: props.text,
maxWidth: props.maxWidth
maxWidth: props.maxWidth,
cycleColor: props.cycleColor
})
const api: ITagApi = {

View File

@ -10,6 +10,7 @@ export interface ITagState {
color: string
mini: boolean
maxWidth: string | number
cycleColor: string
}
export interface ITagApi {

View File

@ -30,6 +30,20 @@
overflow: hidden;
text-overflow: ellipsis;
&-round {
background-color: white !important;
&-cycle {
display: inline-block;
line-height: 100%;
background-color: var(--ti-mobile-tag-color-default);
border-radius: 4px;
width: 8px;
height: 8px;
margin-right: 4px;
}
}
&-mini {
line-height: var(--ti-mobile-tag-height-mini);
padding: 0 var(--ti-mobile-tag-padding-mini);

View File

@ -44,7 +44,8 @@ export const tagProps = {
maxWidth: {
type: [String, Number],
default: null
}
},
cycleColor: String
}
export default defineComponent({

View File

@ -12,9 +12,19 @@
<template>
<div
:class="['tiny-mobile-tag', 'tiny-mobile-tag-' + state.color, state.mini ? 'tiny-mobile-tag-mini' : null]"
:class="[
'tiny-mobile-tag',
'tiny-mobile-tag-' + state.color,
state.mini ? 'tiny-mobile-tag-mini' : null,
state.type === 'round' ? `tiny-mobile-tag-round` : null
]"
:style="{ maxWidth: state.maxWidth ? `${state.maxWidth}px` : null }"
>
<div
v-if="state.type === 'round'"
class="tiny-mobile-tag-round-cycle"
:style="{ backgroundColor: state.cycleColor }"
></div>
<slot>{{ state.text }}</slot>
</div>
</template>
@ -27,7 +37,7 @@ import '@opentiny/vue-theme-mobile/tag/index.less'
export default defineComponent({
emits: ['click', 'close'],
props: [...props, 'text', 'color', 'width', 'mini', 'maxWidth'],
props: [...props, 'text', 'color', 'width', 'mini', 'maxWidth', 'type', 'cycleColor'],
setup(props, context) {
return setup({ props, context, renderless, api, h }) as unknown as ITagApi
}