Skip to content

Commit

Permalink
Merge pull request #509 from EshaanAgg/kimg_app
Browse files Browse the repository at this point in the history
feat: add `appearanceOverrides` prop to `KImg`
  • Loading branch information
MisRob authored Jan 15, 2024
2 parents 7166a00 + 693b017 commit 3cb2b83
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions docs/pages/kimg.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,41 @@
altText="Computers are run by bees"
/>
</DocsShowCode>
</div>

<div>
You can also use the <DocsInternalLink href="#prop:appearanceOverrides">
appearanceOverrides prop
</DocsInternalLink> to add custom styles to the image. It accepts any Vue dynamic styles object and applies the same with the highest precedence.
<DocsShow>
<KImg
:src="require('../assets/img_sample_for_kimg.png')"
altText="Computers are run by bees"
:width="'100%'"
:appearanceOverrides="{
width: '50%',
border: '2px solid black',
padding: '10px',
borderRadius: '5px'
}
"
/>
</DocsShow>
<DocsShowCode language="html">
<KImg
:src="require('../assets/img_sample_for_kimg.png')"
altText="Computers are run by bees"
:width="'100%'"
:appearanceOverrides="{
width: '50%',
border: '2px solid black',
padding: '10px',
borderRadius: '5px'
}
"
/>
</DocsShowCode>
Even thought the <code>width</code> prop specifies the width of the image to be <code>100%</code>, the <code>appearanceOverrides</code> prop overrides it and sets the width to <code>50%</code>.
</div>
</DocsPageSection>
</DocsPageTemplate>
Expand Down
9 changes: 9 additions & 0 deletions lib/KImg.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -91,6 +99,7 @@
minHeight: this.imgMinHeight,
maxWidth: this.imgMaxWidth,
minWidth: this.imgMinWidth,
...this.appearanceOverrides,
},
};
},
Expand Down

0 comments on commit 3cb2b83

Please sign in to comment.