Skip to content

Commit

Permalink
feat(components): [el-badge] support color of type when is-dot (#3279)
Browse files Browse the repository at this point in the history
* feat(components): [el-badge] apply color of type when isDot

* fix(components): [el-badge] change default type to danger
  • Loading branch information
adaex committed Sep 7, 2021
1 parent 8d1a4c5 commit 6408d3c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
14 changes: 14 additions & 0 deletions packages/components/badge/__tests__/badge.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
5 changes: 3 additions & 2 deletions packages/components/badge/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
},
Expand Down

0 comments on commit 6408d3c

Please sign in to comment.