Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use component with :is #3774

Merged
merged 1 commit into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/NcBreadcrumb/NcBreadcrumb.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ This component is meant to be used inside a Breadcrumbs component.
@dragover.prevent="() => {}"
@dragenter="dragEnter"
@dragleave="dragLeave">
<element :is="tag"
<component :is="tag"
v-if="(title || icon) && !$slots.default"
:exact="exact"
:to="to"
Expand All @@ -51,7 +51,7 @@ This component is meant to be used inside a Breadcrumbs component.
<span v-if="icon" :class="icon" class="icon" />
<span v-else>{{ title }}</span>
</slot>
</element>
</component>
<NcActions v-if="$slots.default"
ref="actions"
type="tertiary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export default {
</docs>

<template>
<element :is="wrapperElement"
<component :is="wrapperElement"
:class="{
['checkbox-radio-switch-' + type]: type,
'checkbox-radio-switch--checked': isChecked,
Expand All @@ -171,15 +171,15 @@ export default {
class="checkbox-radio-switch__input"
@change="onToggle">
<NcLoadingIcon v-if="loading" class="checkbox-radio-switch__icon" />
<icon :is="checkboxRadioIconElement"
<component :is="checkboxRadioIconElement"
v-else-if="!buttonVariant"
:size="size"
class="checkbox-radio-switch__icon" />

<!-- @slot The checkbox/radio label -->
<slot />
</label>
</element>
</component>
</template>

<script>
Expand Down
18 changes: 10 additions & 8 deletions src/components/NcUserBubble/NcUserBubble.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,17 @@ This component has the following slot:

</docs>
<template>
<NcPopover :is="isPopoverComponent"
<component :is="isPopoverComponent"
trigger="hover focus"
:shown="open"
class="user-bubble__wrapper"
@update:open="onOpenChange">
<!-- Main userbubble structure -->
<template #trigger>
<div v-bind="isLinkComponent"
<component :is="isLinkComponent"
class="user-bubble__content"
:style="styles.content"
:href="hasUrl ? url : null"
:class="primary ? 'user-bubble__content--primary' : ''"
@click="onClick">
<!-- NcAvatar -->
Expand All @@ -102,12 +103,12 @@ This component has the following slot:
<span v-if="$slots.title" class="user-bubble__secondary">
<slot name="title" />
</span>
</div>
</component>
</template>

<!-- @slot Main Popover content on userbubble hover/focus -->
<slot />
</NcPopover>
</component>
</template>

<script>
Expand Down Expand Up @@ -241,11 +242,12 @@ export default {
return !!this.avatarImage
},

hasUrl() {
return this.url && this.url.trim() !== ''
},

isLinkComponent() {
if (this.url && this.url.trim() !== '') {
return { is: 'a', href: this.url }
}
return { is: 'div' }
return this.hasUrl ? 'a' : 'div'
},

popoverEmpty() {
Expand Down