-
Notifications
You must be signed in to change notification settings - Fork 95
Use NcActions component for NcAvatar
#4017
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,15 +112,16 @@ export default { | |
| v-click-outside="closeMenu" | ||
| :class="{ | ||
| 'avatardiv--unknown': userDoesNotExist, | ||
| 'avatardiv--with-menu': hasMenu | ||
| 'avatardiv--with-menu': hasMenu, | ||
| 'avatardiv--with-menu-loading': contactsMenuLoading | ||
| }" | ||
| :title="tooltip" | ||
| :style="avatarStyle" | ||
| class="avatardiv popovermenu-wrapper" | ||
| :tabindex="hasMenu ? '0' : undefined" | ||
| :aria-label="avatarAriaLabel" | ||
| :role="hasMenu ? 'button' : undefined" | ||
| v-on="hasMenu ? { click: toggleMenu } : {}" | ||
| @click="toggleMenu" | ||
| @keydown.enter="toggleMenu"> | ||
| <!-- @slot Icon slot --> | ||
| <slot name="icon"> | ||
|
|
@@ -133,20 +134,32 @@ export default { | |
| </slot> | ||
|
|
||
| <!-- Contact menu --> | ||
| <NcPopover v-if="hasMenu" | ||
| placement="auto" | ||
| :container="menuContainer" | ||
| :shown="contactsMenuOpenState" | ||
| @after-show="handlePopoverAfterShow" | ||
| @after-hide="handlePopoverAfterHide"> | ||
| <NcPopoverMenu ref="popoverMenu" :menu="menu" /> | ||
| <template #trigger> | ||
| <!-- We show a button if the menu is not loaded yet. --> | ||
| <NcButton v-if="hasMenu && menu.length==0" | ||
| :aria-label="t('Open contact menu')" | ||
| type="tertiary-no-background" | ||
| class="action-item action-item__menutoggle"> | ||
| <template #icon> | ||
| <NcLoadingIcon v-if="contactsMenuLoading" /> | ||
| <DotsHorizontal v-else | ||
| :size="20" | ||
| class="icon-more" /> | ||
| <DotsHorizontal v-else :size="20" /> | ||
| </template> | ||
| </NcButton> | ||
| <NcActions v-else-if="hasMenu" | ||
| force-menu | ||
| manual-open | ||
| type="tertiary-no-background" | ||
| :container="menuContainer" | ||
| :open="contactsMenuOpenState"> | ||
| <NcActionLink v-for="(item, key) in menu" | ||
| :key="key" | ||
| :href="item.href" | ||
| :icon="item.icon"> | ||
| {{ item.text }} | ||
| </NcActionLink> | ||
| <template v-if="contactsMenuLoading" #icon> | ||
| <NcLoadingIcon /> | ||
| </template> | ||
| </NcPopover> | ||
| </NcActions> | ||
|
|
||
| <!-- Avatar status --> | ||
| <div v-if="showUserStatusIconOnAvatar" class="avatardiv__user-status avatardiv__user-status--icon"> | ||
|
|
@@ -168,8 +181,9 @@ export default { | |
| </template> | ||
|
|
||
| <script> | ||
| import NcPopover from '../NcPopover/index.js' | ||
| import NcPopoverMenu from '../NcPopoverMenu/index.js' | ||
| import NcActions from '../NcActions/index.js' | ||
| import NcActionLink from '../NcActionLink/index.js' | ||
| import NcButton from '../NcButton/index.js' | ||
| import NcLoadingIcon from '../NcLoadingIcon/index.js' | ||
| import usernameToColor from '../../functions/usernameToColor/index.js' | ||
| import { userStatus } from '../../mixins/index.js' | ||
|
|
@@ -215,9 +229,10 @@ export default { | |
| }, | ||
| components: { | ||
| DotsHorizontal, | ||
| NcActions, | ||
| NcActionLink, | ||
| NcButton, | ||
| NcLoadingIcon, | ||
| NcPopover, | ||
| NcPopoverMenu, | ||
| }, | ||
| mixins: [userStatus], | ||
| props: { | ||
|
|
@@ -333,15 +348,6 @@ export default { | |
| default: false, | ||
| }, | ||
|
|
||
| /** | ||
| * Choose the avatar menu alignment. | ||
| * Possible values are `left`, `center`, `right`. | ||
| */ | ||
| menuPosition: { | ||
| type: String, | ||
| default: 'center', | ||
| }, | ||
|
|
||
| /** | ||
| * Selector for the popover menu container | ||
| */ | ||
|
|
@@ -467,7 +473,7 @@ export default { | |
| return { | ||
| href: item.hyperlink, | ||
| icon: item.icon, | ||
| longtext: item.title, | ||
| text: item.title, | ||
| } | ||
| }) | ||
|
|
||
|
|
@@ -531,16 +537,7 @@ export default { | |
| }, | ||
|
|
||
| methods: { | ||
| handlePopoverAfterShow() { | ||
| const links = this.$refs.popoverMenu.$el.getElementsByTagName('a') | ||
| if (links.length) { | ||
| links[0].focus() | ||
| } | ||
| }, | ||
| handlePopoverAfterHide() { | ||
| // bring focus back to the trigger | ||
| this.$refs.main.focus() | ||
| }, | ||
| t, | ||
| handleUserStatusUpdated(state) { | ||
| if (this.user === state.userId) { | ||
| this.userStatus = { | ||
|
|
@@ -710,28 +707,38 @@ export default { | |
|
|
||
| &--with-menu { | ||
| cursor: pointer; | ||
| :deep(.v-popper) { | ||
| .action-item { | ||
| position: absolute; | ||
| top: 0; | ||
| left: 0; | ||
| } | ||
| .icon-more { | ||
| :deep(.action-item__menutoggle) { | ||
| cursor: pointer; | ||
| opacity: 0; | ||
| } | ||
| &:focus, | ||
| &:hover { | ||
| .icon-more { | ||
| &:hover, | ||
| &#{&}-loading { | ||
raimund-schluessler marked this conversation as resolved.
Show resolved
Hide resolved
raimund-schluessler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| :deep(.action-item__menutoggle) { | ||
| opacity: 1; | ||
| } | ||
| img { | ||
| opacity: 0.3; | ||
| } | ||
| } | ||
| .icon-more, | ||
| :deep(.action-item__menutoggle), | ||
| img { | ||
| transition: opacity var(--animation-quick); | ||
| } | ||
| :deep() { | ||
| .button-vue, | ||
| .button-vue__icon { | ||
| height: var(--size); | ||
| min-height: var(--size); | ||
| width: var(--size) !important; | ||
| min-width: var(--size); | ||
| } | ||
| } | ||
|
Comment on lines
+733
to
+741
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add a size/small prop to |
||
| } | ||
|
|
||
| .avatardiv__initials-wrapper { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.