Skip to content

Commit

Permalink
refactor: create JHover and change vue-router component imports
Browse files Browse the repository at this point in the history
* Switching some of the smallest pieces off Vuetify
* Import the typed RouterView and RouterLink versions of the components

Signed-off-by: Fernando Fernández <[email protected]>
  • Loading branch information
ferferga committed Jan 17, 2024
1 parent fe758e2 commit 95b339f
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 88 deletions.
10 changes: 5 additions & 5 deletions frontend/src/components/Item/Identify/IdentifyResults.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<VTooltip location="top">
{{ item.Name }}
</VTooltip>
<VHover v-slot="{ isHovering, props: hoverProps }">
<JHover v-slot="{ isHovering, hoverProps }">
<VImg
:src="item.ImageUrl ?? undefined"
v-bind="hoverProps"
Expand Down Expand Up @@ -41,19 +41,19 @@
</VCardSubtitle>
</VFadeTransition>
</VImg>
</VHover>
</JHover>
</VCard>
</VCol>
</VRow>
</template>

<script setup lang="ts">
import { CardShapes, getShapeFromItemType } from '@/utils/items';
import type {
BaseItemKind,
RemoteSearchResult
BaseItemKind,

Check failure on line 53 in frontend/src/components/Item/Identify/IdentifyResults.vue

View workflow job for this annotation

GitHub Actions / Lint 🔬

Expected indentation of 2 spaces but found 0
RemoteSearchResult

Check failure on line 54 in frontend/src/components/Item/Identify/IdentifyResults.vue

View workflow job for this annotation

GitHub Actions / Lint 🔬

Expected indentation of 2 spaces but found 0
} from '@jellyfin/sdk/lib/generated-client';
import { computed } from 'vue';
import { CardShapes, getShapeFromItemType } from '@/utils/items';
const props = defineProps<{
items: RemoteSearchResult[];
Expand Down
17 changes: 8 additions & 9 deletions frontend/src/components/Item/ItemGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
<div :class="large ? useResponsiveClasses('large-grid') : undefined">
<VirtualGrid
v-if="items.length > 0 && !noVirtual"
v-slot="{ item, style }"
:items="items"
:buffer-multiplier="1.5"
:class="useResponsiveClasses('card-grid-container')">
<template #default="{ item, style }">
<Card
:style="style"
:item="item"
margin
text
overlay
link />
</template>
<Card
:style="style"
:item="item"
margin
text
overlay
link />
</VirtualGrid>
<div
v-else-if="items.length > 0 && noVirtual"
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Playback/DraggableQueue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<template
v-for="(item, index) of playbackManager.queue"
:key="item.Id">
<VHover v-slot="{ isHovering, props: hoverProps }">
<JHover v-slot="{ isHovering, hoverProps }">
<VListItem
v-bind="hoverProps"
:title="item.Name ?? ''"
Expand Down Expand Up @@ -36,7 +36,7 @@
queue />
</template>
</VListItem>
</VHover>
</JHover>
</template>
</span>
</template>
Expand Down
126 changes: 62 additions & 64 deletions frontend/src/components/Playback/PiPVideoPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,71 +7,69 @@
scroll-strategy="none"
content-class="minimized-overlay"
:width="$vuetify.display.mobile ? '60vw' : '25vw'">
<VHover>
<template #default="{ isHovering, props }">
<div
v-bind="props"
class="minimized-video-container" />
<VOverlay
:model-value="isHovering"
v-bind="props"
contained
scrim
height="100%"
width="100%">
<div class="d-flex flex-column">
<div class="d-flex flex-row">
<VBtn
icon
@click="playerElement.toggleFullscreenVideoPlayer">
<VIcon>
<IMdiArrowExpandAll />
</VIcon>
</VBtn>
<VSpacer />
<VBtn
icon
@click="playbackManager.stop">
<VIcon>
<IMdiClose />
</VIcon>
</VBtn>
</div>
<div
class="absolute-cover pointer-events-none d-flex flex-row justify-center align-center">
<VBtn
class="pointer-events-all"
icon
size="large"
@click="() => playbackManager.setPreviousItem()">
<VIcon size="32">
<IMdiSkipPrevious />
</VIcon>
</VBtn>
<VBtn
class="pointer-events-all"
icon
size="x-large"
@click="playbackManager.playPause">
<VIcon size="48">
<IMdiPlay v-if="playbackManager.isPaused" />
<IMdiPause v-else />
</VIcon>
</VBtn>
<VBtn
class="pointer-events-all"
icon
size="large"
@click="playbackManager.setNextItem">
<VIcon size="32">
<IMdiSkipNext />
</VIcon>
</VBtn>
</div>
<JHover v-slot="{ isHovering, hoverProps }">
<div
v-bind="hoverProps"
class="minimized-video-container" />
<VOverlay
:model-value="isHovering"
v-bind="hoverProps"
contained
scrim
height="100%"
width="100%">
<div class="d-flex flex-column">
<div class="d-flex flex-row">
<VBtn
icon
@click="playerElement.toggleFullscreenVideoPlayer">
<VIcon>
<IMdiArrowExpandAll />
</VIcon>
</VBtn>
<VSpacer />
<VBtn
icon
@click="playbackManager.stop">
<VIcon>
<IMdiClose />
</VIcon>
</VBtn>
</div>
</VOverlay>
</template>
</VHover>
<div
class="absolute-cover pointer-events-none d-flex flex-row justify-center align-center">
<VBtn
class="pointer-events-all"
icon
size="large"
@click="() => playbackManager.setPreviousItem()">
<VIcon size="32">
<IMdiSkipPrevious />
</VIcon>
</VBtn>
<VBtn
class="pointer-events-all"
icon
size="x-large"
@click="playbackManager.playPause">
<VIcon size="48">
<IMdiPlay v-if="playbackManager.isPaused" />
<IMdiPause v-else />
</VIcon>
</VBtn>
<VBtn
class="pointer-events-all"
icon
size="large"
@click="playbackManager.setNextItem">
<VIcon size="32">
<IMdiSkipNext />
</VIcon>
</VBtn>
</div>
</div>
</VOverlay>
</JHover>
</VOverlay>
</template>

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Playback/TrackList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<template
v-for="track in tracksOnDisc"
:key="track.Id">
<VHover v-slot="{ isHovering, props: hoverProps }">
<JHover v-slot="{ isHovering, hoverProps }">
<tr
:class="{ 'text-primary': isPlaying(track) }"
v-bind="hoverProps"
Expand Down Expand Up @@ -108,7 +108,7 @@
{{ formatTicks(track.RunTimeTicks || 0) }}
</td>
</tr>
</VHover>
</JHover>
</template>
</template>
</tbody>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Users/UserCard.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<VHover v-slot="{ isHovering, props: hoverProps }">
<JHover v-slot="{ isHovering, hoverProps }">
<div
class="ma-2 d-flex flex-column pointer"
v-bind="hoverProps"
Expand All @@ -19,7 +19,7 @@
{{ user.Name }}
</a>
</div>
</VHover>
</JHover>
</template>

<script setup lang="ts">
Expand Down
14 changes: 14 additions & 0 deletions frontend/src/components/lib/JHover.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<template>
<slot
:is-hovering="isHovering"
:hover-props="{
onmouseover: () => isHovering = true,
onmouseout: () => isHovering = false
}" />
</template>

<script setup lang="ts">
import { shallowRef } from 'vue';
const isHovering = shallowRef(false);
</script>
6 changes: 3 additions & 3 deletions frontend/types/global/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ declare module 'vue' {
ItemMenu: typeof import('./../../src/components/Item/ItemMenu.vue')['default']
ItemsCarousel: typeof import('./../../src/components/Layout/Carousel/Item/ItemsCarousel.vue')['default']
ItemsCarouselTitle: typeof import('./../../src/components/Layout/Carousel/Item/ItemsCarouselTitle.vue')['default']
JHover: typeof import('./../../src/components/lib/JHover.vue')['default']
LikeButton: typeof import('./../../src/components/Buttons/LikeButton.vue')['default']
LoadingIndicator: typeof import('./../../src/components/System/LoadingIndicator.vue')['default']
LocaleSwitcher: typeof import('./../../src/components/System/LocaleSwitcher.vue')['default']
Expand Down Expand Up @@ -121,8 +122,8 @@ declare module 'vue' {
RefreshMetadataDialog: typeof import('./../../src/components/Item/Metadata/RefreshMetadataDialog.vue')['default']
RelatedItems: typeof import('./../../src/components/Item/RelatedItems.vue')['default']
RepeatButton: typeof import('./../../src/components/Buttons/Playback/RepeatButton.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
RouterLink: typeof import('vue-router/auto')['RouterLink']
RouterView: typeof import('vue-router/auto')['RouterView']
ScrollToTopButton: typeof import('./../../src/components/Buttons/ScrollToTopButton.vue')['default']
SearchField: typeof import('./../../src/components/Layout/AppBar/SearchField.vue')['default']
SeasonTabs: typeof import('./../../src/components/Item/SeasonTabs.vue')['default']
Expand Down Expand Up @@ -169,7 +170,6 @@ declare module 'vue' {
VFadeTransition: typeof import('vuetify/components')['VFadeTransition']
VFooter: typeof import('vuetify/components')['VFooter']
VForm: typeof import('vuetify/components')['VForm']
VHover: typeof import('vuetify/components')['VHover']
VIcon: typeof import('vuetify/components')['VIcon']
VImg: typeof import('vuetify/components')['VImg']
VirtualGrid: typeof import('./../../src/components/Layout/VirtualGrid/VirtualGrid.vue')['default']
Expand Down
6 changes: 5 additions & 1 deletion frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ export default defineConfig(({ mode }): UserConfig => {
VueUseComponentsResolver(),
Vuetify3Resolver(),
VueUseDirectiveResolver()
]
],
types: [{
from: 'vue-router/auto',
names: ['RouterLink', 'RouterView']
}]
}),
/**
* This plugin allows to use all icons from Iconify as vue components
Expand Down

0 comments on commit 95b339f

Please sign in to comment.