Skip to content

Commit

Permalink
feat(ui): scale preview thumbs to height
Browse files Browse the repository at this point in the history
  • Loading branch information
sentriz committed Sep 19, 2021
1 parent a989235 commit 59727e2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions frontend/components/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<template v-slot:name>search</template>
</nav-item>
<nav-item :to="{ name: 'importer' }">
<template v-slot:icon><eye-icon class="h-5" /></template>
<template v-slot:icon><document-search-icon class="h-5" /></template>
<template v-slot:name>importer</template>
</nav-item>
<nav-item :to="{ name: 'settings' }">
Expand All @@ -29,5 +29,5 @@

<script setup lang="ts">
import NavItem from './NavItem.vue'
import { SearchIcon, CogIcon, EyeIcon, LogoutIcon } from '@heroicons/vue/outline'
import { SearchIcon, DocumentSearchIcon, CogIcon, LogoutIcon } from '@heroicons/vue/outline'
</script>
17 changes: 9 additions & 8 deletions frontend/components/MediaHighlight.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<template>
<div class="w-fit relative">
<video v-if="rich && media?.type === MediaType.Video" :controls="true" @loadstart="loaded">
<div v-if="thumb && media?.type === MediaType.Video" class="top-2 right-2 bg-black/80 absolute p-2 rounded-md">
<video-camera-icon class="h-5 text-white" />
</div>
<video v-if="!thumb && media?.type === MediaType.Video" :controls="true" @loadstart="loaded">
<source :src="url" :type="media.mime" />
</video>
<img v-else :src="url" @load="loaded" />
<svg
v-if="media && blocks.length"
:viewBox="`0 0 ${media.dim_width} ${media.dim_height}`"
Expand All @@ -18,9 +22,6 @@
:height="b.max_y - b.min_y"
/>
</svg>
<div v-if="!rich && media?.type === MediaType.Video" class="top-2 right-2 bg-black/80 absolute p-2 rounded-md">
<video-camera-icon class="h-5 text-white" />
</div>
</div>
</template>
Expand All @@ -32,7 +33,7 @@ import useStore from '../composables/useStore'
const props = defineProps<{
hash?: string
rich?: boolean
thumb?: boolean
}>()
const emit = defineEmits<{ (e: 'loaded'): void }>()
Expand All @@ -44,8 +45,8 @@ const media = computed(() => store.getMediaByHash(props.hash || ''))
const blocks = computed(() => store.getHighlightedBlocksByHash(props.hash || ''))
const url = computed(
() =>
props.rich
? `${urlMedia}/${media.value?.hash}/raw` // full image or video
: `${urlMedia}/${media.value?.hash}/thumb`, // ~200px thumb
props.thumb
? `${urlMedia}/${media.value?.hash}/thumb` // ~200px thumb
: `${urlMedia}/${media.value?.hash}/raw`, // full image or video
)
</script>
4 changes: 2 additions & 2 deletions frontend/components/MediaPreview.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<media-background v-if="media" :hash="media.hash" class="box">
<media-highlight rich :hash="media.hash" class="mx-auto" />
<media-background v-if="media" :hash="media.hash" class="box flex justify-center">
<media-highlight :hash="media.hash" />
</media-background>
<loading-spinner v-else class="bg-gray-100" text="processing image" />

Expand Down
8 changes: 4 additions & 4 deletions frontend/components/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<span class="text-gray-500"> page {{ i + 1 }}</span>
<hr class="m-0" />
</div>
<div class="col-resp gap-x-4 space-y-4">
<media-background v-for="hash in page" :key="hash" :hash="hash" class="shadow-lg">
<router-link :to="{ name: 'search', params: { hash } }">
<media-highlight :hash="hash" class="mx-auto" />
<div class="col-resp col-gap-4 space-y-4">
<media-background v-for="hash in page" :key="hash" :hash="hash" class="shadow-lg max-h-[400px] overflow-y-hidden">
<router-link :to="{ name: 'search', params: { hash } }" class="block">
<media-highlight thumb :hash="hash" />
</router-link>
</media-background>
</div>
Expand Down

0 comments on commit 59727e2

Please sign in to comment.