aboutsummaryrefslogtreecommitdiffstats
path: root/core/src/components/AccountMenu/AccountMenuEntry.vue
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2024-07-29 14:05:45 +0200
committerFerdinand Thiessen <opensource@fthiessen.de>2024-08-06 09:20:48 +0200
commit674805c9948460df49592d187f5bb9a4cb8f4b56 (patch)
treee24330290bba266b1aba9d67aa4e344013e5ebc7 /core/src/components/AccountMenu/AccountMenuEntry.vue
parent69814cd4f7e48f5f998c192064f8dc2e2bbba73a (diff)
downloadnextcloud-server-674805c9948460df49592d187f5bb9a4cb8f4b56.tar.gz
nextcloud-server-674805c9948460df49592d187f5bb9a4cb8f4b56.zip
fix(core): Migrate UserMenu / AccountMenu to NcListItem
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'core/src/components/AccountMenu/AccountMenuEntry.vue')
-rw-r--r--core/src/components/AccountMenu/AccountMenuEntry.vue103
1 files changed, 103 insertions, 0 deletions
diff --git a/core/src/components/AccountMenu/AccountMenuEntry.vue b/core/src/components/AccountMenu/AccountMenuEntry.vue
new file mode 100644
index 00000000000..47ce884fc2b
--- /dev/null
+++ b/core/src/components/AccountMenu/AccountMenuEntry.vue
@@ -0,0 +1,103 @@
+<!--
+ - SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ - SPDX-License-Identifier: AGPL-3.0-or-later
+-->
+
+<template>
+ <NcListItem :id="href ? undefined : id"
+ :anchor-id="id"
+ :active="active"
+ class="account-menu-entry"
+ compact
+ :href="href"
+ :name="name"
+ target="_self">
+ <template #icon>
+ <img class="account-menu-entry__icon"
+ :class="{ 'account-menu-entry__icon--active': active }"
+ :src="iconSource"
+ alt="">
+ </template>
+ <template v-if="loading" #indicator>
+ <NcLoadingIcon />
+ </template>
+ </NcListItem>
+</template>
+
+<script>
+import { loadState } from '@nextcloud/initial-state'
+
+import NcListItem from '@nextcloud/vue/dist/Components/NcListItem.js'
+import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
+
+const versionHash = loadState('core', 'versionHash', '')
+
+export default {
+ name: 'AccountMenuEntry',
+
+ components: {
+ NcListItem,
+ NcLoadingIcon,
+ },
+
+ props: {
+ id: {
+ type: String,
+ required: true,
+ },
+ name: {
+ type: String,
+ required: true,
+ },
+ href: {
+ type: String,
+ required: true,
+ },
+ active: {
+ type: Boolean,
+ required: true,
+ },
+ icon: {
+ type: String,
+ required: true,
+ },
+ },
+
+ data() {
+ return {
+ loading: false,
+ }
+ },
+
+ computed: {
+ iconSource() {
+ return `${this.icon}?v=${versionHash}`
+ },
+ },
+
+ methods: {
+ handleClick() {
+ this.loading = true
+ },
+ },
+}
+</script>
+
+<style lang="scss" scoped>
+.account-menu-entry {
+ &__icon {
+ height: 20px;
+ width: 20px;
+ margin: calc((var(--default-clickable-area) - 20px) / 2); // 20px icon size
+ filter: var(--background-invert-if-dark);
+
+ &--active {
+ filter: var(--primary-invert-if-dark);
+ }
+ }
+
+ :deep(.list-item-content__main) {
+ width: fit-content;
+ }
+}
+</style>