mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-09 14:46:47 +08:00
Fix image preview and status icon for items card [SCI-9480] (#6413)
This commit is contained in:
parent
45cfe77ef7
commit
e0148cca31
3 changed files with 40 additions and 6 deletions
|
@ -4,7 +4,7 @@
|
||||||
{{ colName }}
|
{{ colName }}
|
||||||
</div>
|
</div>
|
||||||
<div v-if="file_name" @mouseover="tooltipShowing = true" @mouseout="tooltipShowing = false"
|
<div v-if="file_name" @mouseover="tooltipShowing = true" @mouseout="tooltipShowing = false"
|
||||||
class="w-fit cursor-pointer text-sn-science-blue">
|
class="w-fit cursor-pointer text-sn-science-blue relative">
|
||||||
<a @click="$emit('closeSidebar')" class="file-preview-link" :id="modalPreviewLinkId" data-no-turbolink="true"
|
<a @click="$emit('closeSidebar')" class="file-preview-link" :id="modalPreviewLinkId" data-no-turbolink="true"
|
||||||
data-id="true" data-status="asset-present" :data-preview-url=this.preview_url :href=this.url>
|
data-id="true" data-status="asset-present" :data-preview-url=this.preview_url :href=this.url>
|
||||||
{{ file_name }}
|
{{ file_name }}
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
<div class="font-inter text-sm font-semibold leading-5">
|
<div class="font-inter text-sm font-semibold leading-5">
|
||||||
{{ colName }}
|
{{ colName }}
|
||||||
</div>
|
</div>
|
||||||
<div v-if="status && icon" class="text-sn-dark-grey font-inter text-sm font-normal leading-5 ">
|
<div v-if="status && icon" class="flex flex-row items-center text-sn-dark-grey font-inter text-sm font-normal leading-5 ">
|
||||||
<i class="text-lg">{{ icon }}</i>
|
<div v-html="parseEmoji(icon)" class="flex mr-1.5 h-6"></div>
|
||||||
{{ status }}
|
{{ status }}
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="text-sn-dark-grey font-inter text-sm font-normal leading-5">
|
<div v-else class="text-sn-dark-grey font-inter text-sm font-normal leading-5">
|
||||||
|
@ -14,6 +14,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
import twemoji from 'twemoji';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'RepositoryStatusValue',
|
name: 'RepositoryStatusValue',
|
||||||
data() {
|
data() {
|
||||||
|
@ -33,6 +36,11 @@ export default {
|
||||||
this.id = this.colVal.id
|
this.id = this.colVal.id
|
||||||
this.icon = this.colVal.icon
|
this.icon = this.colVal.icon
|
||||||
this.status = this.colVal.status
|
this.status = this.colVal.status
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
parseEmoji(content) {
|
||||||
|
return twemoji.parse(content);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,13 +1,20 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="absolute">
|
<div>
|
||||||
<img :src="this.medium_preview_url"
|
<img :src="this.medium_preview_url" @load="onImageLoaded($event)"
|
||||||
class="absolute bg-sn-light-grey text-sn-black w-[300px] h-[260px] rounded pointer-events-none flex shadow-lg shrink-0" />
|
class="absolute bg-sn-light-grey text-sn-black rounded pointer-events-none flex shadow-lg"
|
||||||
|
:class="{ hidden: !showImage, 'top-0 transform -translate-y-full': showTop }"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'TooltipPreview',
|
name: 'TooltipPreview',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
showTop: false,
|
||||||
|
showImage: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
props: {
|
props: {
|
||||||
tooltipId: String,
|
tooltipId: String,
|
||||||
url: String,
|
url: String,
|
||||||
|
@ -16,5 +23,24 @@ export default {
|
||||||
icon_html: String || null,
|
icon_html: String || null,
|
||||||
medium_preview_url: String || null,
|
medium_preview_url: String || null,
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
onImageLoaded(event) {
|
||||||
|
this.showTop = !this.isInViewPort(event.target);
|
||||||
|
this.showImage = true;
|
||||||
|
},
|
||||||
|
|
||||||
|
isInViewPort(el) {
|
||||||
|
if (!el) return;
|
||||||
|
|
||||||
|
const height = el.naturalHeight;
|
||||||
|
const rect = el.parentElement.getBoundingClientRect();
|
||||||
|
|
||||||
|
return (
|
||||||
|
(rect.bottom + height) <=
|
||||||
|
(window.innerHeight || document.documentElement.clientHeight)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Reference in a new issue