diff --git a/CHANGELOG.md b/CHANGELOG.md index 436a7834a..007595020 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ Changelog is rather internal in nature. See release notes for the public overvie ## Upcoming version +- [#509] + - **Description:** Introduces `appearanceOverrides` prop for the `KImg` component + - **Products impact:** new API + - **Addresses:** https://github.com/learningequality/kolibri-design-system/issues/371 + - **Components:** KImg + - **Breaking:** No + - **Impacts a11y:** No + - **Guidance:** - + +[#509]: https://github.com/learningequality/kolibri-design-system/pull/509 - [#516] - **Description:** Upgrades follow-redirects dependency - **Products impact:** Dependency upgrade diff --git a/docs/pages/kimg.vue b/docs/pages/kimg.vue index 9e738f74f..a28103f6d 100644 --- a/docs/pages/kimg.vue +++ b/docs/pages/kimg.vue @@ -76,7 +76,41 @@ altText="Computers are run by bees" /> + +
+ You can also use the + appearanceOverrides prop + to add custom styles to the image. It accepts any Vue dynamic styles object and applies the same with the highest precedence. + + + + + + + Even thought the width prop specifies the width of the image to be 100%, the appearanceOverrides prop overrides it and sets the width to 50%.
diff --git a/lib/KImg.vue b/lib/KImg.vue index 3ab6eaccf..e2dc212ce 100644 --- a/lib/KImg.vue +++ b/lib/KImg.vue @@ -81,6 +81,14 @@ type: [Number, String], default: undefined, }, + /** + * Accepts a Vue dynamic styles object to override the default styles to modify the appearance of the component. + * It's attributes always take precedence over any specified styling (internal component's styles, styles calculated from props etc.) + */ + appearanceOverrides: { + type: Object, + default: () => ({}), + }, }, data() { return { @@ -91,6 +99,7 @@ minHeight: this.imgMinHeight, maxWidth: this.imgMaxWidth, minWidth: this.imgMinWidth, + ...this.appearanceOverrides, }, }; },