Skip to content

Commit e72428b

Browse files
committed
add correct icon check, moved some conditional logic to a computed prop
1 parent c4f55dc commit e72428b

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

design-library/src/components/BccBadge/BccBadge.vue

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<script setup lang="ts">
22
import { BCC_CONTEXTS } from "@/composables/contexts";
33
import type { VueComponent } from "@/types";
4+
import { computed, defineProps, withDefaults } from "vue";
45
5-
withDefaults(
6+
const props = withDefaults(
67
defineProps<{
78
icon?: VueComponent;
89
iconRight?: boolean | VueComponent;
@@ -19,20 +20,23 @@ withDefaults(
1920
context: "neutral",
2021
}
2122
);
23+
24+
const shouldShowRightIcon = computed(() => {
25+
return (props.iconRight && typeof props.iconRight !== 'boolean') || (props.icon && props.iconRight === true)
26+
})
2227
</script>
2328

2429
<template>
2530
<div class="bcc-badge" :class="[BCC_CONTEXTS[context], contrast, size, { bordered }]">
2631
<component
27-
v-if="icon && !iconRight"
32+
v-if="icon && iconRight !== true"
2833
:is="icon"
2934
class="bcc-badge-icon order-1"
3035
/>
3136
<span class="order-2 empty:hidden"><slot></slot></span>
3237
<component
3338
v-if="shouldShowRightIcon"
34-
v-if="rightIconComponent"
35-
:is="rightIconComponent"
39+
:is="typeof iconRight !== 'boolean' ? iconRight : icon"
3640
class="bcc-badge-icon order-3"
3741
/>
3842
</div>

0 commit comments

Comments
 (0)