aboutsummaryrefslogtreecommitdiffstats
path: root/core/src/components/AppMenuIcon.vue
blob: f2cee75e644bb5668c339fb7f2e7547fea811679 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!--
 - SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
 - SPDX-License-Identifier: AGPL-3.0-or-later
 -->

<template>
	<span class="app-menu-icon"
		role="img"
		:aria-hidden="ariaHidden"
		:aria-label="ariaLabel">
		<img class="app-menu-icon__icon" :src="app.icon" alt="">
		<IconDot v-if="app.unread" class="app-menu-icon__unread" :size="10" />
	</span>
</template>

<script setup lang="ts">
import type { INavigationEntry } from '../types/navigation'
import { n } from '@nextcloud/l10n'
import { computed } from 'vue'

import IconDot from 'vue-material-design-icons/Circle.vue'

const props = defineProps<{
	app: INavigationEntry
}>()

const ariaHidden = computed(() => String(props.app.unread > 0))

const ariaLabel = computed(() => {
	if (ariaHidden.value === 'true') {
		return ''
	}
	return props.app.name
		+ (props.app.unread > 0 ? ` (${n('core', '{count} notification', '{count} notifications', props.app.unread, { count: props.app.unread })})` : '')
})
</script>

<style scoped lang="scss">
$icon-size: 20px;
$unread-indicator-size: 10px;

.app-menu-icon {
	box-sizing: border-box;
	position: relative;

	height: $icon-size;
	width: $icon-size;

	&__icon {
		transition: margin 0.1s ease-in-out;
		height: $icon-size;
		width: $icon-size;
		filter: var(--background-image-invert-if-bright);
	}

	&__unread {
		color: var(--color-error);
		position: absolute;
		// Align the dot to the top right corner of the icon
		inset-block-end: calc($icon-size + ($unread-indicator-size / -2));
		inset-inline-end: calc($unread-indicator-size / -2);
		transition: all 0.1s ease-in-out;
	}
}
</style>