add feature to have two icons at the same time#336
Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for displaying two icons simultaneously in the BccBadge component - one on the left and one on the right side of the badge text.
- Modified the
iconRightprop to accept either a boolean or a VueComponent, enabling it to serve as both a positioning flag and an icon definition - Added computed logic to determine when the right icon should be displayed
- Updated the template to render separate left and right icon components with proper ordering
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| const shouldShowRightIcon = computed(() => { | ||
| return (props.iconRight && typeof props.iconRight !== 'boolean') || (props.icon && props.iconRight === true) | ||
| }) |
There was a problem hiding this comment.
[nitpick] The logic for determining when to show the right icon is complex and could be simplified. Consider extracting the conditions into separate boolean variables with descriptive names like hasCustomRightIcon and hasIconMovedRight for better readability.
| }) | |
| const hasCustomRightIcon = computed(() => props.iconRight && typeof props.iconRight !== 'boolean'); | |
| const hasIconMovedRight = computed(() => props.icon && props.iconRight === true); | |
| const shouldShowRightIcon = computed(() => hasCustomRightIcon.value || hasIconMovedRight.value); |
| <div class="bcc-badge" :class="[BCC_CONTEXTS[context], contrast, size, { bordered }]"> | ||
| <component | ||
| v-if="icon" | ||
| v-if="icon && iconRight !== true" |
There was a problem hiding this comment.
The condition iconRight !== true is checking against a prop that can now be a boolean or VueComponent. This logic could be clearer by explicitly checking the type or using a computed property to determine when the left icon should be shown.
Change summary
without making breaking changes for previous versions
Change type
Closes #ISSUE_NUMBER or Part of #ISSUE_NUMBER