Skip to content

A self-hosted media server and file management system

fix: popover items don't support dividers and dont pass $attrs.class to inner button

aminnausin9c87fc2c1cda
diff --git a/resources/js/components/cedar-ui/context-menu/ContextMenuItem.vue b/resources/js/components/cedar-ui/context-menu/ContextMenuItem.vue
index 93a59cd8..bd486414 100644
--- a/resources/js/components/cedar-ui/context-menu/ContextMenuItem.vue
+++ b/resources/js/components/cedar-ui/context-menu/ContextMenuItem.vue
@@ -8,6 +8,8 @@ import { cn } from '@aminnausin/cedar-ui';
import ProiconsChevronRight from '~icons/proicons/chevron-right';
+defineOptions({ inheritAttrs: false });
+
const props = withDefaults(defineProps<ContextMenuItem & { divider?: boolean; children?: ContextMenuItem[]; submenuStyle?: string; showLeftIcon?: boolean }>(), {
selectedStyle: 'dark:text-primary',
showLeftIcon: true,
@@ -38,6 +40,7 @@ useMutationObserver(subMenu, () => (isFloating.value = subMenu.value?.dataset.fl
cn(
'hocus:bg-overlay-accent focus-visible:ring-foreground-0 h-7 w-full justify-start rounded-md px-2 py-1.5 ring ring-transparent select-none ring-inset focus:outline-none dark:focus-visible:bg-neutral-950/90',
style,
+ $attrs.class,
)
"
:disabled="disabled"
diff --git a/resources/js/components/video/VideoInfoPanel.vue b/resources/js/components/video/VideoInfoPanel.vue
index e70ee6ca..140cf21d 100755
--- a/resources/js/components/video/VideoInfoPanel.vue
+++ b/resources/js/components/video/VideoInfoPanel.vue
@@ -86,6 +86,7 @@ const popoverItems = computed(() => {
hidden: !stateDirectory.value.downloads_enabled || !stateFolder.value.series?.downloads_enabled,
disabled: !stateVideo.value.id,
},
+ { divider: true, hidden: !isAuthenticated.value },
{
icon: IconEdit,
text: 'Edit Metadata',
@@ -274,12 +275,11 @@ onMounted(() => {
<template #content>
<ContextMenuItem
v-for="popoverItem in popoverItems.filter((itm) => !itm.hidden)"
+ v-bind="popoverItem"
:key="popoverItem.text"
- :icon="popoverItem.icon"
- :text="popoverItem.text"
- :disabled="popoverItem.disabled"
:action="
() => {
+ if (!popoverItem.action) return;
mobilePopover?.handleClose();
popoverItem.action();
}
@@ -414,12 +414,11 @@ onMounted(() => {
<template #content>
<ContextMenuItem
v-for="popoverItem in popoverItems.filter((itm) => itm.text !== 'Edit Metadata' && !itm.hidden)"
+ v-bind="popoverItem"
:key="popoverItem.text"
- :icon="popoverItem.icon"
- :text="popoverItem.text"
- :disabled="popoverItem.disabled"
:action="
() => {
+ if (!popoverItem.action) return;
popover?.handleClose();
popoverItem.action();
}
diff --git a/resources/js/components/video/audio/PlayerAudioTracks.vue b/resources/js/components/video/audio/PlayerAudioTracks.vue
index 912e2e9b..a29eebd4 100644
--- a/resources/js/components/video/audio/PlayerAudioTracks.vue
+++ b/resources/js/components/video/audio/PlayerAudioTracks.vue
@@ -1,4 +1,5 @@
<script setup lang="ts">
+import type { PopoverItem } from '@/types/types';
import type { Ref } from 'vue';
import { computed, inject, onMounted, ref, useTemplateRef } from 'vue';
@@ -30,7 +31,7 @@ const player = inject<Ref<HTMLVideoElement>>('player');
const activeTracks = ref<AudioTrack[]>([]);
const activeTrackId = ref<string>();
-const playerAudioTracks = computed(() =>
+const playerAudioTracks = computed<PopoverItem[]>(() =>
activeTracks.value.map((track) => {
const lang = track.language || 'und';
const text = toTitleCase([lang, track.id].filter(Boolean).join(' '));
@@ -103,8 +104,13 @@ defineExpose({ audioTracksPopover });
<IconSpeech class="ms-0.5 mb-0.5 size-4.5" />
</template>
<template #content>
- <section :class="['scrollbar-minimal flex h-fit max-h-21 flex-col overflow-y-auto transition-transform md:max-h-35', { 'pe-0.5': playerAudioTracks.length > 3 }]">
- <VideoPopoverItem v-for="(item, index) in playerAudioTracks" :key="index" v-bind="item" class="capitalize *:truncate" />
+ <section
+ :class="[
+ 'scrollbar-minimal group/popover-items flex h-fit max-h-21 flex-col overflow-y-auto transition-transform md:max-h-35',
+ { 'pe-0.5': playerAudioTracks.length > 3 },
+ ]"
+ >
+ <VideoPopoverItem v-for="(item, index) in playerAudioTracks" :key="index" v-bind="item" :class="{ 'capitalize *:truncate': !item.divider }" />
</section>
</template>
</VideoPopover>
diff --git a/resources/js/components/video/popover/VideoPopover.vue b/resources/js/components/video/popover/VideoPopover.vue
index a6d56757..dadba2e8 100644
--- a/resources/js/components/video/popover/VideoPopover.vue
+++ b/resources/js/components/video/popover/VideoPopover.vue
@@ -141,7 +141,7 @@ onUnmounted(() => {
v-if="popoverOpen"
:class="
cn(
- 'scrollbar-dark absolute right-2 z-7 w-75 max-w-lg overflow-clip rounded-md border border-neutral-700/10 bg-neutral-800/90 p-1 shadow-xs backdrop-blur-xs',
+ 'scrollbar-dark absolute right-2 z-7 w-75 max-w-lg overflow-clip rounded-md border border-neutral-700/10 bg-neutral-800/90 py-1 shadow-xs backdrop-blur-xs',
verticalOffset ? `bottom-${verticalOffset}` : `bottom-16`, // This wont generate classes
popoverClass,
)
diff --git a/resources/js/components/video/popover/VideoPopoverItem.vue b/resources/js/components/video/popover/VideoPopoverItem.vue
index bd5a5596..b8326d5b 100644
--- a/resources/js/components/video/popover/VideoPopoverItem.vue
+++ b/resources/js/components/video/popover/VideoPopoverItem.vue
@@ -3,46 +3,54 @@ import type { PopoverItem } from '@/types/types';
import { cn } from '@aminnausin/cedar-ui';
+defineOptions({ inheritAttrs: false });
+
const props = withDefaults(defineProps<PopoverItem>(), {});
</script>
<template>
- <button
- :title="title ?? ''"
- :class="
- cn(
- 'disabled:button-disabled transition-input flex w-full cursor-pointer items-center rounded-md px-2 py-1.5 text-xs ease-in-out select-none',
- 'ring-white outline-hidden ring-inset hover:bg-neutral-900 focus:bg-neutral-950 focus:outline-none focus-visible:ring',
- { selectedStyle: selected },
- { hidden: disabled },
- style,
- )
- "
- :onclick="action"
- :data="disabled"
- >
- <component v-if="icon" :is="icon" :class="cn('mr-2 size-4 shrink-0', iconStyle)" />
+ <div v-if="divider" class="bg-hr dark:bg-hr/30 my-1 h-px shrink-0 group-[.pe-0\.5]/popover-items:-me-0.5" />
+
+ <div v-else class="px-1">
+ <button
+ v-bind="$attrs"
+ :title="title ?? ''"
+ :class="
+ cn(
+ 'disabled:button-disabled transition-input flex w-full cursor-pointer items-center rounded-md px-2 py-1.5 text-xs ease-in-out select-none',
+ 'ring-white outline-hidden ring-inset hover:bg-neutral-900 focus:bg-neutral-950 focus:outline-none focus-visible:ring',
+ { selectedStyle: selected },
+ { hidden: disabled },
+ style,
+ $attrs.class,
+ )
+ "
+ :onclick="action"
+ :data="disabled"
+ >
+ <component v-if="icon" :is="icon" :class="cn('mr-2 size-4 shrink-0', iconStyle)" />
- <span class="text-nowrap">{{ text }}</span>
- <span class="ml-auto text-xs tracking-widest opacity-60">{{ shortcut ?? '' }}</span>
- <slot name="selectedIcon">
- <component
- v-if="selectedIcon"
- :is="selectedIcon"
- :class="cn('size-4 shrink-0', { 'text-primary-muted dark:text-primary': selected }, selected ? selectedIconStyle : 'invisible')"
- />
- <span
- v-else
- width="24"
- height="24"
- viewBox="0 0 24 24"
- fill="none"
- stroke="currentColor"
- stroke-width="2"
- stroke-linecap="round"
- stroke-linejoin="round"
- class="size-4 shrink-0"
- >
- </span>
- </slot>
- </button>
+ <span class="text-nowrap">{{ text }}</span>
+ <span class="ml-auto text-xs tracking-widest opacity-60">{{ shortcut ?? '' }}</span>
+ <slot name="selectedIcon">
+ <component
+ v-if="selectedIcon"
+ :is="selectedIcon"
+ :class="cn('size-4 shrink-0', { 'text-primary-muted dark:text-primary': selected }, selected ? selectedIconStyle : 'invisible')"
+ />
+ <span
+ v-else
+ width="24"
+ height="24"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ stroke-width="2"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ class="size-4 shrink-0"
+ >
+ </span>
+ </slot>
+ </button>
+ </div>
</template>
diff --git a/resources/js/components/video/popover/VideoPopoverSlider.vue b/resources/js/components/video/popover/VideoPopoverSlider.vue
index dae50954..e142409b 100644
--- a/resources/js/components/video/popover/VideoPopoverSlider.vue
+++ b/resources/js/components/video/popover/VideoPopoverSlider.vue
@@ -5,6 +5,8 @@ import { ButtonBase } from '@/components/cedar-ui/button';
import { useId } from 'vue';
import { cn } from '@aminnausin/cedar-ui';
+defineOptions({ inheritAttrs: false });
+
const id = useId();
const props = withDefaults(defineProps<PopoverSlider>(), { min: 10, max: 200, step: 5 });
@@ -16,46 +18,50 @@ const resetModel = () => {
};
</script>
<template>
- <label
- v-show="!hidden"
- :for="id"
- :title="title ?? 'Popover Slider'"
- :class="
- cn(
- 'transition-input flex w-full flex-wrap items-center gap-y-2 rounded-md px-2 py-1.5 text-xs',
- 'ring-white outline-hidden ring-inset focus-within:bg-neutral-950 hover:bg-neutral-900 focus:outline-none has-focus-visible:ring',
- { 'button-disabled': disabled },
- style,
- )
- "
- @dblclick="resetModel"
- @wheel="wheelAction"
- >
- <component v-if="icon" :is="icon" class="mr-2 size-4 shrink-0" />
-
- <span class="text-nowrap">{{ text }}</span>
- <ButtonBase
- v-if="defaultValue !== undefined"
- type="button"
- class="text-foreground-1 dark ml-auto h-fit cursor-pointer p-0 text-xs tracking-wide focus-visible:outline-offset-2"
- :title="defaultValue !== undefined ? `Reset ${text}` : undefined"
- @click="resetModel"
+ <div class="px-1">
+ <label
+ v-show="!hidden"
+ v-bind="$attrs"
+ :for="id"
+ :title="title ?? 'Popover Slider'"
+ :class="
+ cn(
+ 'transition-input flex w-full flex-wrap items-center gap-y-2 rounded-md px-2 py-1.5 text-xs',
+ 'ring-white outline-hidden ring-inset focus-within:bg-neutral-950 hover:bg-neutral-900 focus:outline-none has-focus-visible:ring',
+ { 'button-disabled': disabled },
+ style,
+ $attrs.class,
+ )
+ "
+ @dblclick="resetModel"
+ @wheel="wheelAction"
>
- {{ shortcut }}
- </ButtonBase>
- <span v-else class="text-foreground-1 dark ml-auto cursor-pointer text-xs tracking-wide">
- {{ shortcut }}
- </span>
- <input
- v-model="model"
- type="range"
- :id="id"
- :class="`slider volume h-2 w-full ring-white outline-hidden focus-visible:ring`"
- :min="min"
- :max="max"
- :step="step"
- :disabled="disabled"
- @input="action"
- />
- </label>
+ <component v-if="icon" :is="icon" class="mr-2 size-4 shrink-0" />
+
+ <span class="text-nowrap">{{ text }}</span>
+ <ButtonBase
+ v-if="defaultValue !== undefined"
+ type="button"
+ class="text-foreground-1 dark ml-auto h-fit cursor-pointer p-0 text-xs tracking-wide focus-visible:outline-offset-2"
+ :title="defaultValue !== undefined ? `Reset ${text}` : undefined"
+ @click="resetModel"
+ >
+ {{ shortcut }}
+ </ButtonBase>
+ <span v-else class="text-foreground-1 dark ml-auto cursor-pointer text-xs tracking-wide">
+ {{ shortcut }}
+ </span>
+ <input
+ v-model="model"
+ type="range"
+ :id="id"
+ :class="`slider volume h-2 w-full ring-white outline-hidden focus-visible:ring`"
+ :min="min"
+ :max="max"
+ :step="step"
+ :disabled="disabled"
+ @input="action"
+ />
+ </label>
+ </div>
</template>
diff --git a/resources/js/components/video/subtitles/PlayerSubtitles.vue b/resources/js/components/video/subtitles/PlayerSubtitles.vue
index 43321d6a..9c2aa100 100644
--- a/resources/js/components/video/subtitles/PlayerSubtitles.vue
+++ b/resources/js/components/video/subtitles/PlayerSubtitles.vue
@@ -1,6 +1,6 @@
<script setup lang="ts">
import type { SubtitleResource } from '@/types/resources';
-import type { PopoverItem } from '@aminnausin/cedar-ui';
+import type { PopoverItem } from '@/types/types';
import type { Ref } from 'vue';
import { computed, inject, nextTick, onMounted, onUnmounted, ref, useTemplateRef, watch } from 'vue';
@@ -50,7 +50,7 @@ const subtitleSizeDelta = 0.1;
const subtitlesPopover = useTemplateRef('subtitles-popover');
-const playerSubtitleItems = computed(() => {
+const playerSubtitleItems = computed<PopoverItem[]>(() => {
const items: PopoverItem[] = stateVideo.value.subtitles.map((track) => {
const isCurrentTrack = isShowingSubtitles.value && currentSubtitleTrack.value?.id === track.id;
@@ -99,7 +99,7 @@ const playerSubtitleItems = computed(() => {
action: clearSubtitles,
};
- return [toggleFonts, subtitlesOff, ...items].filter(Boolean);
+ return [toggleFonts, { divider: true }, subtitlesOff, ...items].filter(Boolean);
});
const defaultSubtitleTrack = computed<SubtitleResource | undefined>(() => {
@@ -307,7 +307,12 @@ defineExpose({
<IconCaptionsOff v-else class="*:stroke-1.5 size-4" />
</template>
<template #content>
- <section :class="['scrollbar-minimal flex h-fit max-h-21 flex-col overflow-y-auto transition-transform md:max-h-35', { 'pe-0.5': playerSubtitleItems.length > 3 }]">
+ <section
+ :class="[
+ 'scrollbar-minimal group/popover-items flex h-fit max-h-21 flex-col overflow-y-auto transition-transform md:max-h-35',
+ { 'pe-0.5': playerSubtitleItems.length > 3 },
+ ]"
+ >
<VideoPopoverSlider
v-if="playerSubtitleItems.length > 1 && currentSubtitleTrack && currentSubtitleTrack?.codec !== 'ass'"
v-model="subtitleSizeMultiplier"
@@ -321,7 +326,7 @@ defineExpose({
:wheel-action="handleSizeWheel"
:title="'Change Subtitle Font Size'"
/>
- <VideoPopoverItem v-for="(item, index) in playerSubtitleItems" :key="index" v-bind="item" class="*:truncate" />
+ <VideoPopoverItem v-for="(item, index) in playerSubtitleItems" :key="index" v-bind="item" :class="{ '*:truncate': !item.divider }" />
</section>
</template>
</VideoPopover>
diff --git a/resources/js/types/types.ts b/resources/js/types/types.ts
index a7c4a2e8..8afc417e 100644
--- a/resources/js/types/types.ts
+++ b/resources/js/types/types.ts
@@ -91,6 +91,11 @@ export interface PopoverItem {
icon?: Component;
selectedIcon?: Component;
hidden?: boolean;
+
+ divider?: boolean;
+ children?: ContextMenuItem[];
+ submenuStyle?: string;
+ showLeftIcon?: boolean;
}
export interface PopoverSlider {