Skip to content

Commit

Permalink
prop heading level throws necessary warnings if not stastified
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanOXDi committed Feb 25, 2024
1 parent fdb2149 commit 9a60b73
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 14 deletions.
2 changes: 0 additions & 2 deletions docs/pages/playground.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
<!-- Play around with your component here: -->




</div>

</template>
Expand Down
53 changes: 43 additions & 10 deletions lib/KCard/BaseCard.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,48 @@
<template>

<li class="remove-list-style">
<h2
v-if="title !== null"
:headerLevelTag="headerLevelTag"
>
<a :href="to">
<KTextTruncator :text="title" :maxLines="1" />
</a>
</h2>
</li>
<div
:class="$computedClass({ ':focus': $coreOutline })"
>
<li class="remove-list-style">

<h2
v-if="title !== null && headingLevel === 2"
>
<a :href="to">
<KTextTruncator :text="title" :maxLines="1" />
</a>
</h2>
<h3
v-if="title !== null && headingLevel === 3"
>
<a :href="to">
<KTextTruncator :text="title" :maxLines="1" />
</a>
</h3>
<h4
v-if="title !== null && headingLevel === 4"
>
<a :href="to">
<KTextTruncator :text="title" :maxLines="1" />
</a>
</h4>
<h5
v-if="title !== null && headingLevel === 5"
>
<a :href="to">
<KTextTruncator :text="title" :maxLines="1" />
</a>
</h5>
<h6
v-if="title !== null && headingLevel === 6"
>
<a :href="to">
<KTextTruncator :text="title" :maxLines="1" />
</a>
</h6>

</li>
</div>

</template>

Expand Down
9 changes: 7 additions & 2 deletions lib/KCard/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<div
class="card"
:class="$computedClass({ ':focus': $coreOutline })"
tabindex="0"
@focus="cardFocus"
@hover="cardHover"
Expand Down Expand Up @@ -41,7 +40,13 @@
console.error(`Missing headinglevel ${value}`);
return false;
} else {
return true;
const headingLevelRange = [2, 3, 4, 5, 6];
if (!headingLevelRange.includes(value)) {
console.error(`Headinglevel ${value} is not in range 2-6`);
return false;
} else {
return true;
}
}
},
},
Expand Down

0 comments on commit 9a60b73

Please sign in to comment.