Skip to content

Commit

Permalink
isDecorative removed.
Browse files Browse the repository at this point in the history
Signed-off-by: shivangrawat30 <[email protected]>
  • Loading branch information
ShivangRawat30 committed Oct 11, 2023
1 parent ff15d1a commit b5774e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
8 changes: 3 additions & 5 deletions docs/pages/KLogo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,20 @@
</div>

<div class="img-example-2">
<DocsLibraryLink component="KLogo" /> requires alternative text that describes the image unless
<code>isDecorative</code> is <code>true</code>. In that case, any alt text provided will be overwritten to an
empty string.
<DocsLibraryLink component="KLogo" /> requires alternative text that describes the image, or it will throw an error.
<div>
<div>
<DocsShow>
<KLogo
isDecorative
altText="kolibriLogo"
:height="50"
:width="50"
/>
</DocsShow>
</div>
<DocsShowCode language="html">
<KLogo
isDecorative
altText="kolibriLogo"
:height="50"
:width="50"
/>
Expand Down
23 changes: 8 additions & 15 deletions lib/KLogo/index.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<template>

<div>
<img
<KImg
:src="logo"
:alt="alternateText"
:altText="alternateText"
:style="styleObject"
>
<slot></slot>
/>
</div>

</template>

<script>
import KImg from '../KImg.vue';
import kolibriLogo from './kolibri-logo.svg';
export default {
Expand All @@ -25,13 +25,6 @@
type: String,
default: '',
},
/**
* Sets the image as decorative. This sets the alt image property to an empty string.
*/
isDecorative: {
type: Boolean,
default: false,
},
/**
* Sets the height for the component
*/
Expand Down Expand Up @@ -89,7 +82,7 @@
},
computed: {
alternateText() {
return this.isDecorative ? '' : this.altText;
return this.altText;
},
imgHeight() {
return this.validateAndFormatUnits(this.height);
Expand All @@ -114,8 +107,9 @@
},
},
created() {
if (!this.isDecorative && !this.altText) {
throw new Error('Missing required prop - provide altText or indicate isDecorative');
console.log(this.altText);
if (!this.altText) {
throw new Error('Missing required prop - provide altText');
}
},
methods: {
Expand All @@ -141,7 +135,6 @@
'vh',
'vw',
];
// if made up of valid numbers and valid units
if (!isNaN(arr[0]) && validUnits.includes(arr[1])) {
return propValue;
Expand Down

0 comments on commit b5774e0

Please sign in to comment.