-
-
Notifications
You must be signed in to change notification settings - Fork 569
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: record menu supports duplicate record (#1060)
* feat: record menu supports duplicate record * fix: the display of card covers * fix: linting types * fix: the click penetration of dialog
- Loading branch information
Showing
26 changed files
with
183 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
apps/nextjs-app/src/features/app/blocks/view/gallery/components/CardCarousel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import type { IAttachmentCellValue } from '@teable/core'; | ||
import { isSystemFileIcon, getFileCover } from '@teable/sdk/components'; | ||
import { useAttachmentPreviewI18Map } from '@teable/sdk/components/hooks'; | ||
import { FilePreviewProvider, FilePreviewItem } from '@teable/ui-lib/base'; | ||
import { | ||
Carousel, | ||
CarouselContent, | ||
CarouselItem, | ||
CarouselPrevious, | ||
CarouselNext, | ||
} from '@teable/ui-lib/shadcn'; | ||
import { Fragment } from 'react'; | ||
import { CARD_COVER_HEIGHT } from '../utils'; | ||
|
||
interface ICardCarouselProps { | ||
value: IAttachmentCellValue; | ||
isCoverFit?: boolean; | ||
} | ||
|
||
export const CardCarousel = (props: ICardCarouselProps) => { | ||
const { value, isCoverFit } = props; | ||
const i18nMap = useAttachmentPreviewI18Map(); | ||
|
||
return ( | ||
<FilePreviewProvider i18nMap={i18nMap}> | ||
<Carousel | ||
opts={{ | ||
watchDrag: false, | ||
watchResize: false, | ||
watchSlides: false, | ||
}} | ||
className="border-b" | ||
> | ||
<CarouselContent className="ml-0"> | ||
{value.map(({ id, name, size, mimetype, presignedUrl, lgThumbnailUrl }) => { | ||
const isSystemFile = isSystemFileIcon(mimetype); | ||
const url = lgThumbnailUrl ?? getFileCover(mimetype, presignedUrl); | ||
return ( | ||
<CarouselItem | ||
key={id} | ||
style={{ height: CARD_COVER_HEIGHT }} | ||
className="relative size-full pl-0" | ||
> | ||
<FilePreviewItem | ||
key={id} | ||
className="flex size-full cursor-pointer items-center justify-center" | ||
src={presignedUrl || ''} | ||
name={name} | ||
mimetype={mimetype} | ||
size={size} | ||
> | ||
<img | ||
src={url} | ||
alt="card cover" | ||
className={isSystemFile ? 'size-20' : 'size-full'} | ||
style={{ | ||
objectFit: isCoverFit ? 'contain' : 'cover', | ||
}} | ||
/> | ||
</FilePreviewItem> | ||
</CarouselItem> | ||
); | ||
})} | ||
</CarouselContent> | ||
{value.length > 1 && ( | ||
<Fragment> | ||
<CarouselPrevious className="left-1 size-7" onClick={(e) => e.stopPropagation()} /> | ||
<CarouselNext className="right-1 size-7" onClick={(e) => e.stopPropagation()} /> | ||
</Fragment> | ||
)} | ||
</Carousel> | ||
</FilePreviewProvider> | ||
); | ||
}; |
2 changes: 2 additions & 0 deletions
2
apps/nextjs-app/src/features/app/blocks/view/gallery/components/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './Card'; | ||
export * from './CardCarousel'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.