Browse Source

feat: navigate carousel by clicking cover image

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/3379/head
mertmit 2 years ago
parent
commit
f8ee8c2b49
  1. 22
      packages/nc-gui-v2/components/smartsheet/Gallery.vue

22
packages/nc-gui-v2/components/smartsheet/Gallery.vue

@ -105,7 +105,7 @@ const expandForm = (row: RowType, state?: Record<string, any>) => {
const expandFormClick = async (e: MouseEvent, row: RowType) => { const expandFormClick = async (e: MouseEvent, row: RowType) => {
const target = e.target as HTMLElement const target = e.target as HTMLElement
if (target && !target.closest('.slick-dots')) { if (target && !target.closest('.gallery-carousel')) {
expandForm(row) expandForm(row)
} }
} }
@ -123,12 +123,18 @@ openNewRecordFormHook?.on(async () => {
<Row :row="record"> <Row :row="record">
<a-card hoverable class="!rounded-lg h-full overflow-hidden break-all" @click="expandFormClick($event, record)"> <a-card hoverable class="!rounded-lg h-full overflow-hidden break-all" @click="expandFormClick($event, record)">
<template #cover> <template #cover>
<a-carousel v-if="!reloadAttachments && attachments(record).length" autoplay class="gallery-carousel"> <a-carousel v-if="!reloadAttachments && attachments(record).length" autoplay class="gallery-carousel" arrows>
<template #customPaging> <template #customPaging>
<a> <a>
<div class="pt-[12px]"><div></div></div> <div class="pt-[12px]"><div></div></div>
</a> </a>
</template> </template>
<template #prevArrow>
<div style="z-index: 1"></div>
</template>
<template #nextArrow>
<div style="z-index: 1"></div>
</template>
<img <img
v-for="(attachment, index) in attachments(record).filter((attachment) => attachment.url)" v-for="(attachment, index) in attachments(record).filter((attachment) => attachment.url)"
:key="`carousel-${record.row.id}-${index}`" :key="`carousel-${record.row.id}-${index}`"
@ -206,4 +212,16 @@ openNewRecordFormHook?.on(async () => {
.ant-carousel.gallery-carousel :deep(.slick-dots li.slick-active div > div) { .ant-carousel.gallery-carousel :deep(.slick-dots li.slick-active div > div) {
opacity: 1; opacity: 1;
} }
.ant-carousel.gallery-carousel :deep(.slick-prev) {
left: 0;
height: 100%;
top: 12px;
width: 50%;
}
.ant-carousel.gallery-carousel :deep(.slick-next) {
right: 0;
height: 100%;
top: 12px;
width: 50%;
}
</style> </style>

Loading…
Cancel
Save