Skip to content

Commit

Permalink
Merge pull request #3774 from nextcloud/fix/noid/component-element
Browse files Browse the repository at this point in the history
Use component with :is
  • Loading branch information
raimund-schluessler authored Feb 17, 2023
2 parents a388f53 + 2813e64 commit 667c2a2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
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

0 comments on commit 667c2a2

Please sign in to comment.