33
33
34
34
```vue
35
35
<template>
36
- <NcAppNavigationItem name="My name">
37
- <template #icon>
38
- <Check :size="20" />
39
- </template>
40
- </NcAppNavigationItem>
36
+ <ul>
37
+ <NcAppNavigationItem name="With icon slot">
38
+ <template #icon>
39
+ <Check :size="20" />
40
+ </template>
41
+ </NcAppNavigationItem>
42
+ <NcAppNavigationItem name="With icon class" icon="icon-group-white" />
43
+ <NcAppNavigationItem name="With svg icon" :icon="iconAccountSvg" />
44
+ <NcAppNavigationItem name="With @mdi/js icon" :icon="mdiAbacus" />
45
+ </ul>
41
46
</template>
42
47
<script>
48
+ import { mdiAbacus } from '@mdi/js'
49
+
43
50
import Check from 'vue-material-design-icons/Check'
51
+ import iconAccountSvg from '@mdi/svg/svg/account.svg?raw'
44
52
45
53
export default {
46
54
components: {
47
55
Check,
48
56
},
57
+ data() {
58
+ return {
59
+ iconAccountSvg,
60
+ mdiAbacus,
61
+ }
62
+ },
49
63
}
50
64
</script>
51
65
```
@@ -285,10 +299,18 @@ Just set the `pinned` prop.
285
299
286
300
<!-- icon if not collapsible -->
287
301
<!-- never show the icon over the collapsible if mobile -->
288
- <div :class =" { [icon]: icon }"
289
- class =" app-navigation-entry-icon" >
302
+ <div class =" app-navigation-entry-icon" >
290
303
<NcLoadingIcon v-if =" loading" />
304
+ <<<<<<< Updated upstream
291
305
<slot v-else name =" icon" />
306
+ =======
307
+ <!-- @slot Slot for the optional leading icon -->
308
+ <slot v-else name =" icon" >
309
+ <NcIconSvgWrapper v-if =" iconPath" :path =" iconPath" />
310
+ <NcIconSvgWrapper v-else-if =" iconSvg" :svg =" iconSvg" />
311
+ <span v-else :class =" { [icon]: icon }" />
312
+ </slot >
313
+ >>>>>>> Stashed changes
292
314
</div >
293
315
<span v-if =" !editingActive" class =" app-navigation-entry__name" >
294
316
{{ name }}
@@ -369,6 +391,7 @@ Just set the `pinned` prop.
369
391
import NcActions from ' ../NcActions/index.js'
370
392
import NcActionButton from ' ../NcActionButton/index.js'
371
393
import NcLoadingIcon from ' ../NcLoadingIcon/index.js'
394
+ import NcIconSvgWrapper from ' ../NcIconSvgWrapper/index.js'
372
395
import NcVNodes from ' ../NcVNodes/index.js'
373
396
import NcAppNavigationIconCollapsible from ' ./NcAppNavigationIconCollapsible.vue'
374
397
import { useIsMobile } from ' ../../composables/useIsMobile/index.js'
@@ -386,6 +409,7 @@ export default {
386
409
NcActions,
387
410
NcActionButton,
388
411
NcAppNavigationIconCollapsible,
412
+ NcIconSvgWrapper,
389
413
NcInputConfirmCancel,
390
414
NcLoadingIcon,
391
415
NcVNodes,
@@ -429,8 +453,8 @@ export default {
429
453
},
430
454
431
455
/**
432
- * Refers to the icon on the left, this prop accepts a class
433
- * like 'icon-category-enabled'.
456
+ * Refers to the icon on the left
457
+ * Either pass an icon as raw SVG string, path from `@mdi/js` or icon class like 'icon-category-enabled'.
434
458
*/
435
459
icon: {
436
460
type: String ,
@@ -619,6 +643,20 @@ export default {
619
643
},
620
644
621
645
computed: {
646
+ /**
647
+ * Check if icon property might be an SVG as it starts with < which is not a valid class nor a valid path
648
+ */
649
+ iconSvg () {
650
+ return this .icon .startsWith (' <' ) ? this .icon : undefined
651
+ },
652
+
653
+ /**
654
+ * Check if icon property is not an SVG and contains a space so it is not an css class
655
+ */
656
+ iconPath () {
657
+ return ! this .iconSvg && this .icon .includes (' ' ) ? this .icon : undefined
658
+ },
659
+
622
660
isRouterLink () {
623
661
return this .to && ! this .href
624
662
},
0 commit comments