Skip to content

Commit

Permalink
Merge pull request #5912 from nextcloud-libraries/backport/5708/next
Browse files Browse the repository at this point in the history
[next] feat(NcUserBubble): add RouterLink support
  • Loading branch information
raimund-schluessler committed Aug 5, 2024
2 parents 0f4f2f4 + e715ff1 commit 2473dbc
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/components/NcUserBubble/NcUserBubble.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default {
<component :is="isLinkComponent"
class="user-bubble__content"
:style="styles.content"
:to="to"
:href="hasUrl ? url : null"
:class="{ 'user-bubble__content--primary': primary }"
v-bind="attrs"
Expand Down Expand Up @@ -108,6 +109,7 @@ import NcUserBubbleDiv from './NcUserBubbleDiv.vue'
import NcAvatar from '../NcAvatar/index.js'
import NcPopover from '../NcPopover/index.js'
import { warn } from 'vue'
import { RouterLink } from 'vue-router'
export default {
name: 'NcUserBubble',
Expand Down Expand Up @@ -160,6 +162,13 @@ export default {
}
},
},
/**
* Use bubble as a router-link for in-app navigation
*/
to: {
type: [String, Object],
default: undefined,
},
/**
* Default popover state. Requires the UserBubble
* to have some content to render inside the popover
Expand Down Expand Up @@ -226,7 +235,9 @@ export default {
},
isLinkComponent() {
return this.hasUrl ? 'a' : 'div'
return this.hasUrl
? (this.to ? RouterLink : 'a')
: 'div'
},
styles() {
Expand Down Expand Up @@ -308,4 +319,7 @@ export default {
}
}
a.user-bubble__content {
cursor: pointer;
}
</style>

0 comments on commit 2473dbc

Please sign in to comment.