Skip to content

Commit

Permalink
Merge pull request #5708 from nextcloud-libraries/fix/noid/user-bubbl…
Browse files Browse the repository at this point in the history
…e-clickable

feat(NcUserBubble): add RouterLink support
  • Loading branch information
Antreesy authored Aug 5, 2024
2 parents a474ec2 + 6bae996 commit 536f64f
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 Vue 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 @@ -240,7 +249,9 @@ export default {
},

isLinkComponent() {
return this.hasUrl ? 'a' : 'div'
return this.hasUrl
? (this.to ? RouterLink : 'a')
: 'div'
},

popoverEmpty() {
Expand Down Expand Up @@ -329,4 +340,7 @@ export default {
}
}

a.user-bubble__content {
cursor: pointer;
}
</style>

0 comments on commit 536f64f

Please sign in to comment.