feat: 完成 badge 的按需样式

This commit is contained in:
就眠儀式 2022-04-12 08:36:54 +08:00
parent 7ec26120be
commit 32b7cbb7ab
4 changed files with 59 additions and 52 deletions

View File

@ -31,6 +31,7 @@
border-width: 1px; border-width: 1px;
border-style: solid; border-style: solid;
background-color: #fff; background-color: #fff;
border-color: @global-neutral-color-3;
color: #666; color: #666;
} }
@ -57,3 +58,27 @@
opacity: 0; opacity: 0;
} }
} }
/** Badge 在与其他组件配合使用时的辅助样式 */
.layui-btn .layui-badge,
.layui-btn .layui-badge-dot {
margin-left: 5px;
}
.layui-nav .layui-badge,
.layui-nav .layui-badge-dot {
position: absolute;
top: 50%;
margin: -5px 6px 0;
}
.layui-nav .layui-badge {
margin-top: -10px;
}
.layui-tab-title .layui-badge,
.layui-tab-title .layui-badge-dot {
left: 5px;
top: -2px;
}

View File

@ -26,7 +26,6 @@ const classes = computed(() => {
"layui-badge-dot-ripple": props.ripple, "layui-badge-dot-ripple": props.ripple,
}, },
`layui-bg-${props.theme}`, `layui-bg-${props.theme}`,
]; ];
}); });
@ -37,9 +36,11 @@ const styles = computed(() => {
<template> <template>
<span :class="classes" :style="styles"> <span :class="classes" :style="styles">
<span v-if="type === 'dot'" <span
v-if="type === 'dot'"
:class="props.theme ? `layui-bg-${props.theme}` : ``" :class="props.theme ? `layui-bg-${props.theme}` : ``"
:style="styles ?? `background-color: #ff5722;`"> :style="styles ?? `background-color: #ff5722;`"
>
</span> </span>
<slot v-if="type != 'dot'"></slot> <slot v-if="type != 'dot'"></slot>

View File

@ -43,6 +43,10 @@ const matchComponents = [
pattern: /^LayEmpty$/, pattern: /^LayEmpty$/,
styleDir: "empty", styleDir: "empty",
}, },
{
pattern: /^LayBadge$/,
styleDir: "badge",
},
// .... // ....
{ {
pattern: /^LayAvatarList$/, pattern: /^LayAvatarList$/,

View File

@ -376,7 +376,6 @@ a cite {
color: #666 !important; color: #666 !important;
} }
.layui-badge-rim,
.layui-border, .layui-border,
.layui-colla-content, .layui-colla-content,
.layui-colla-item, .layui-colla-item,
@ -1229,28 +1228,6 @@ a cite {
margin: 0 15px; margin: 0 15px;
} }
.layui-btn .layui-badge,
.layui-btn .layui-badge-dot {
margin-left: 5px;
}
.layui-nav .layui-badge,
.layui-nav .layui-badge-dot {
position: absolute;
top: 50%;
margin: -5px 6px 0;
}
.layui-nav .layui-badge {
margin-top: -10px;
}
.layui-tab-title .layui-badge,
.layui-tab-title .layui-badge-dot {
left: 5px;
top: -2px;
}
.layui-fixbar { .layui-fixbar {
position: fixed; position: fixed;
right: 15px; right: 15px;