diff --git a/docs/pages/kicon.vue b/docs/pages/kicon.vue
index c4aa74cb2..f7b2b6800 100644
--- a/docs/pages/kicon.vue
+++ b/docs/pages/kicon.vue
@@ -3,6 +3,8 @@
See for design guidance and a list of available icons.
+ If an invalid icon is used, in development Vue.js validation will warn about the error.
+ The icon will display as a broken image icon.
diff --git a/docs/rstIconReplacements.txt b/docs/rstIconReplacements.txt
index 6bc778115..c5a808e6f 100644
--- a/docs/rstIconReplacements.txt
+++ b/docs/rstIconReplacements.txt
@@ -8,6 +8,7 @@
.. |back| replace:: :raw-html:``
.. |bookmarkEmpty| replace:: :raw-html:``
.. |bookmark| replace:: :raw-html:``
+.. |brokenImage| replace:: :raw-html:``
.. |channel| replace:: :raw-html:``
.. |checked| replace:: :raw-html:``
.. |check| replace:: :raw-html:``
diff --git a/lib/KIcon/iconDefinitions.js b/lib/KIcon/iconDefinitions.js
index 1dea79c3a..04a66bc7f 100644
--- a/lib/KIcon/iconDefinitions.js
+++ b/lib/KIcon/iconDefinitions.js
@@ -1,4 +1,4 @@
-import { themeTokens } from '../styles/theme';
+import { themePalette, themeTokens } from '../styles/theme';
/**
* Defines all icons in the Kolibri Design System
@@ -60,6 +60,10 @@ const KolibriIcons = {
icon: require('./precompiled-icons/material-icons/error/baseline.vue').default,
defaultColor: themeTokens().error,
},
+ brokenImage: {
+ icon: require('./precompiled-icons/material-icons/broken_image/baseline.vue').default,
+ defaultColor: themePalette().grey.v_400,
+ },
// Features and links
learn: { icon: require('./precompiled-icons/material-icons/school/baseline.vue').default },
diff --git a/lib/KIcon/index.vue b/lib/KIcon/index.vue
index ed0d92118..4ebb1afc6 100644
--- a/lib/KIcon/index.vue
+++ b/lib/KIcon/index.vue
@@ -50,22 +50,28 @@
},
},
computed: {
+ selectedIcon() {
+ if (!KolibriIcons[this.icon]) {
+ return KolibriIcons.brokenImage;
+ }
+ return KolibriIcons[this.icon];
+ },
computedColor() {
if (this.disableColor) {
return null;
}
if (this.color) {
return this.color;
- } else if (KolibriIcons[this.icon].defaultColor) {
- return KolibriIcons[this.icon].defaultColor;
+ } else if (this.selectedIcon.defaultColor) {
+ return this.selectedIcon.defaultColor;
}
return this.$themeTokens.text;
},
rtlFlip() {
- return KolibriIcons[this.icon].rtlFlip && this.isRtl;
+ return this.selectedIcon.rtlFlip && this.isRtl;
},
svgIconComponent() {
- return KolibriIcons[this.icon].icon;
+ return this.selectedIcon.icon;
},
},
};