feat(components): [el-badge] support color of type when is-dot (#3279)

* feat(components): [el-badge] apply color of type when isDot

* fix(components): [el-badge] change default type to danger
This commit is contained in:
Aex 2021-09-07 17:17:39 +08:00 committed by GitHub
parent 8d1a4c5ea6
commit 6408d3cce6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -24,6 +24,20 @@ describe('Badge', () => {
slots: { default: AXIOM },
})
expect(wrapper.find('.el-badge__content.is-dot').exists()).toBe(true)
expect(
wrapper.find('.el-badge__content.el-badge__content--danger').exists()
).toBe(true)
})
test('is dot with type', () => {
const wrapper = mount(Badge, {
props: { isDot: true, type: 'success' },
slots: { default: AXIOM },
})
expect(wrapper.find('.el-badge__content.is-dot').exists()).toBe(true)
expect(
wrapper.find('.el-badge__content.el-badge__content--success').exists()
).toBe(true)
})
test('max', async () => {

View File

@ -6,9 +6,10 @@
v-show="!hidden && (content || content === 0 || isDot)"
class="el-badge__content"
:class="[
isDot ? 'is-dot' : 'el-badge__content--' + type,
'el-badge__content--' + type,
{
'is-fixed': $slots.default,
'is-dot': isDot,
},
]"
v-text="content"
@ -36,7 +37,7 @@ export default defineComponent({
hidden: Boolean,
type: {
type: String,
default: 'primary',
default: 'danger',
validator: (val: string) => {
return ['primary', 'success', 'warning', 'info', 'danger'].includes(val)
},