Skip to content

A self-hosted media server and file management system

feat: player toolbar button

aminnausinc90b991e89c2
diff --git a/resources/js/components/video/VideoLyrics.vue b/resources/js/components/video/VideoLyrics.vue
index 3fcd097e..d8d5395c 100644
--- a/resources/js/components/video/VideoLyrics.vue
+++ b/resources/js/components/video/VideoLyrics.vue
@@ -7,9 +7,9 @@ import { useContentStore } from '@/stores/ContentStore';
import { useModalStore } from '@/stores/ModalStore';
import { useLyricStore } from '@/stores/LyricStore';
import { storeToRefs } from 'pinia';
-import { ButtonText } from '@/components/cedar-ui/button';
import { onSeek } from '@/service/player/seekBus';
+import PlayerToolbarButton from '@/components/video/button/PlayerToolbarButton.vue';
import VideoLyricItem from '@/components/video/VideoLyricItem.vue';
let unsubscribe: () => boolean;
@@ -19,7 +19,7 @@ const { handleGenerateLyrics, handleOpenLyricsModal } = useLyricStore();
const { stateVideo } = storeToRefs(useContentStore());
const emit = defineEmits<{ seek: [value: number] }>();
-const props = defineProps<{ rawLyrics: string; player: HTMLVideoElement | null; timeDuration: number; isPaused: boolean }>();
+const props = defineProps<{ rawLyrics: string; player: HTMLVideoElement | null; timeDuration: number; isPaused: boolean; isShowingLyrics: boolean }>();
const lyrics = computed(() => {
const availableLyrics = stateLyrics.value;
@@ -252,19 +252,11 @@ defineExpose({ scrollToCurrent });
</section>
<div class="pointer-events-auto absolute top-0 right-0 left-0 h-12" style="z-index: 6"></div>
<div class="pointer-events-auto absolute right-0 bottom-0 left-0 h-16" style="z-index: 6"></div>
- <div class="absolute top-4 right-4 flex gap-1" style="z-index: 7">
- <ButtonText
- variant="ghost"
- :class="[
- dirtyLyric ? 'opacity-90' : 'bg-transparent opacity-70',
- 'hocus:bg-neutral-900/30 hocus:text-yellow-500 hocus:opacity-100 pointer-events-auto h-6 rounded-full bg-neutral-900/10 py-1!',
- ]"
- @click="handleOpenLyricsModal"
- title="Edit Lyrics"
- >
+ <Teleport defer to="#player-toolbar" v-if="isShowingLyrics">
+ <PlayerToolbarButton @click="handleOpenLyricsModal" title="Edit lyrics" :is-active="!!dirtyLyric">
{{ dirtyLyric ? 'preview' : 'edit' }}
- </ButtonText>
- </div>
+ </PlayerToolbarButton>
+ </Teleport>
</template>
<style lang="css" scoped>
diff --git a/resources/js/components/video/VideoPartyPanel.vue b/resources/js/components/video/VideoPartyPanel.vue
index ecb37bff..6b4e4e45 100644
--- a/resources/js/components/video/VideoPartyPanel.vue
+++ b/resources/js/components/video/VideoPartyPanel.vue
@@ -6,18 +6,19 @@ import { storeToRefs } from 'pinia';
import { toast } from '@aminnausin/cedar-ui';
import { ref } from 'vue';
+import PlayerToolbarButton from '@/components/video/button/PlayerToolbarButton.vue';
import VideoPartyItem from '@/components/video/VideoPartyItem.vue';
-import VideoPopover from '@/components/video/VideoPopover.vue';
import VideoButton from '@/components/video/VideoButton.vue';
import LucideLogOut from '~icons/lucide/log-out';
import ProiconsEye from '~icons/proicons/eye';
import ProiconsAdd from '~icons/proicons/add';
-defineProps<{ player?: HTMLVideoElement }>();
+defineProps<{ isShowingParty?: boolean }>();
const { userData } = storeToRefs(useAuthStore());
+const isShowingPanel = ref(false);
const partyUsers = ref<UserResource[]>([
{
id: 2560,
@@ -42,31 +43,32 @@ const handleKickUser = (id: number) => {
</script>
<template>
- <VideoPopover
- v-if="userData?.id"
- popoverClass="max-w-40! rounded-lg right-4"
- ref="popover-party"
- :margin="80"
- :player="player ?? undefined"
- :force-popover-position="'bottom'"
- button-class="hover:bg-neutral-900/60 bg-neutral-900/30 p-1 rounded-full hover:scale-100 scale-90 transition-transform ease-in-out duration-500 flex gap-1 items-center justify-center"
- title="Watch Party"
- >
- <template #buttonIcon>
+ <Teleport defer to="#player-toolbar" v-if="userData?.id && isShowingParty">
+ <PlayerToolbarButton @click="isShowingPanel = !isShowingPanel" :is-active="isShowingPanel" :class="['ps-1']" title="Open watch party panel">
<ProiconsEye class="size-4" />
<p>{{ 1 + partyUsers.length }}</p>
- </template>
- <template #content>
- <section class="scrollbar-minimal xs:h-24 flex h-12 flex-col gap-2 overflow-y-auto p-1 text-xs transition-transform md:h-fit">
- <section class="flex justify-between">
- <h3>Party ({{ 1 + partyUsers.length }}/8)</h3>
- <span class="flex justify-end gap-1">
- <VideoButton :icon="ProiconsAdd" title="Invite to Party" @click="toast('Would open friends list', { type: 'info' })" />
- <VideoButton :icon="LucideLogOut" title="Leave Party" @click="toast('Would leave party', { type: 'info' })" />
- </span>
- </section>
- <VideoPartyItem v-for="user in [userData, ...partyUsers]" :user="user" :key="user.id" :leader-id="1" @kick-user="handleKickUser" />
- </section>
- </template>
- </VideoPopover>
+ </PlayerToolbarButton>
+ </Teleport>
+ <div v-if="userData?.id" v-show="isShowingPanel" class="pointer-events-auto w-fit max-w-40 rounded-md border border-neutral-700/10 bg-neutral-800/90 p-2 backdrop-blur-xs">
+ <div class="scrollbar-minimal scrollbar-dark xs:h-24 flex h-12 flex-col gap-2 overflow-y-auto text-xs md:h-fit">
+ <div class="flex items-center justify-between gap-2">
+ <p>Party ({{ 1 + partyUsers.length }}/8)</p>
+ <span class="flex justify-end gap-1">
+ <VideoButton
+ :icon="ProiconsAdd"
+ class="flex size-5 items-center justify-center p-0 *:size-3.5"
+ title="Invite to Party"
+ @click="toast('Would open friends list', { type: 'info' })"
+ />
+ <VideoButton
+ :icon="LucideLogOut"
+ class="flex size-5 items-center justify-center p-0 *:size-3.5"
+ title="Leave Party"
+ @click="toast('Would leave party', { type: 'info' })"
+ />
+ </span>
+ </div>
+ <VideoPartyItem v-for="user in [userData, ...partyUsers]" :user="user" :key="user.id" :leader-id="1" @kick-user="handleKickUser" />
+ </div>
+ </div>
</template>
diff --git a/resources/js/components/video/button/PlayerToolbarButton.vue b/resources/js/components/video/button/PlayerToolbarButton.vue
new file mode 100644
index 00000000..a0997d23
--- /dev/null
+++ b/resources/js/components/video/button/PlayerToolbarButton.vue
@@ -0,0 +1,50 @@
+<script setup lang="ts">
+import { RouterLink } from 'vue-router';
+import { computed } from 'vue';
+import { cn } from '@aminnausin/cedar-ui';
+
+const props = withDefaults(
+ defineProps<{
+ title?: string;
+ to?: string;
+ targetElement?: HTMLElement;
+ controls?: boolean;
+ verticalOffset?: string;
+ isActive?: boolean;
+ class?: string | any[];
+ }>(),
+ {},
+);
+
+const wrapper = computed(() => {
+ return props.to ? RouterLink : 'button';
+});
+
+const wrapperProps = computed(() => {
+ const semanticTitle = props.to ? 'Link' : 'Button';
+ return {
+ 'aria-label': props.title ?? `Player ${semanticTitle}`,
+ title: props.title ?? `Player ${semanticTitle}`,
+ to: props.to,
+ };
+});
+</script>
+<template>
+ <component
+ ref="el"
+ :is="wrapper"
+ :class="
+ cn(
+ 'flex cursor-pointer items-center gap-1',
+ 'h-5 rounded-full px-2 py-0.5',
+ 'bg-neutral-900/60 text-white/80 hover:bg-white/10 hover:text-yellow-500',
+ 'duration-input transition-colors ease-in',
+ { 'text-foreground-i dark bg-white! hover:text-yellow-600': isActive },
+ props.class,
+ )
+ "
+ v-bind="wrapperProps"
+ >
+ <slot></slot>
+ </component>
+</template>