Skip to content

Commit a1a8203

Browse files
committed
fix: CSidebarNavItem: allow adding 'size' prop in 'icon' object #76
1 parent 44244fd commit a1a8203

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/components/template/CSidebarNavItem.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ export default {
7070
},
7171
computedIcon () {
7272
if (typeof this.icon === 'object') {
73+
const key = this.icon.size ? 'class' : 'customClasses'
7374
return Object.assign(
74-
{ customClasses: 'c-sidebar-nav-icon' },
75+
{ [`${key}`]: 'c-sidebar-nav-icon' },
7576
this.icon
7677
)
7778
} else {

src/components/template/tests/CSidebarNavItem.spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,10 @@ describe(`${ComponentName}.vue`, () => {
4343
it('renders correctly in label mode', () => {
4444
expect(wrapperLabel.element).toMatchSnapshot()
4545
})
46+
it('assign correct classes in case of custom icon size', () => {
47+
wrapperLabel.setProps({ icon: { name: 'cui-settings', size: 'lg' }})
48+
expect(wrapperLabel.find('svg').classes().join(',')).toBe(
49+
'c-icon,c-icon-lg,c-sidebar-nav-icon'
50+
)
51+
})
4652
})

0 commit comments

Comments
 (0)