Files
api/web/components/Notifications/Indicator.vue
Eli Bosley 88087d5201 feat: mount vue apps, not web components (#1639)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Standalone web bundle with auto-mount utilities and a self-contained
test page.
* New responsive modal components for consistent mobile/desktop dialogs.
  * Header actions to copy OS/API versions.

* **Improvements**
* Refreshed UI styles (muted borders), accessibility and animation
refinements.
  * Theming updates and Tailwind v4–aligned, component-scoped styles.
  * Runtime GraphQL endpoint override and CSRF header support.

* **Bug Fixes**
* Safer network fetching and improved manifest/asset loading with
duplicate protection.

* **Tests/Chores**
* Parallel plugin tests, new extractor test suite, and updated
build/test scripts.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-09-03 15:42:21 -04:00

60 lines
1.7 KiB
Vue

<script setup lang="ts">
import { computed } from 'vue';
import type { Component } from 'vue';
import { BellIcon, ExclamationTriangleIcon, ShieldExclamationIcon } from '@heroicons/vue/24/solid';
import { cn } from '@unraid/ui';
import type { OverviewQuery } from '~/composables/gql/graphql';
import { NotificationImportance as Importance } from '~/composables/gql/graphql';
const props = defineProps<{ overview?: OverviewQuery['notifications']['overview']; seen?: boolean }>();
const indicatorLevel = computed(() => {
if (!props.overview?.unread) {
return undefined;
}
switch (true) {
case props.overview.unread.alert > 0:
return Importance.ALERT;
case props.overview.unread.warning > 0:
return Importance.WARNING;
case props.overview.unread.total > 0:
return 'UNREAD';
default:
return undefined;
}
});
const icon = computed<{ component: Component; color: string } | null>(() => {
switch (indicatorLevel.value) {
case Importance.WARNING:
return {
component: ExclamationTriangleIcon,
color: 'text-yellow-500 translate-y-0.5',
};
case Importance.ALERT:
return {
component: ShieldExclamationIcon,
color: 'text-unraid-red',
};
}
return null;
});
</script>
<template>
<div class="relative flex items-center justify-center">
<BellIcon class="w-6 h-6 text-header-text-primary" />
<div
v-if="!seen && indicatorLevel === 'UNREAD'"
class="absolute top-0 right-0 size-2.5 rounded-full border border-muted bg-unraid-green"
/>
<component
:is="icon.component"
v-else-if="!seen && icon && indicatorLevel"
:class="cn('absolute -top-1 -right-1 size-4 rounded-full', icon.color)"
/>
</div>
</template>