From 7c0904688078ee73ec12d1392206cd33f08319d6 Mon Sep 17 00:00:00 2001 From: Akmal Isomadinov Date: Fri, 2 Feb 2024 20:27:23 +0500 Subject: [PATCH] MediaViewer: Added description --- .../media-viewer/MediaViewer.stories.tsx | 16 ++++---- .../media-viewer/MediaViewer.types.ts | 40 ++++++++++++++++--- 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/packages/shared/components/media-viewer/MediaViewer.stories.tsx b/packages/shared/components/media-viewer/MediaViewer.stories.tsx index 9fa64988a5..4aca355e9d 100644 --- a/packages/shared/components/media-viewer/MediaViewer.stories.tsx +++ b/packages/shared/components/media-viewer/MediaViewer.stories.tsx @@ -10,18 +10,18 @@ import i18nextStoryDecorator from "../../.storybook/decorators/i18nextStoryDecor import { Portal } from "../portal"; import { Button } from "../button"; -import { MediaViewer as Media } from "./MediaViewer"; +import { MediaViewer } from "./MediaViewer"; import type { MediaViewerProps, PlaylistType } from "./MediaViewer.types"; -type MediaViewerType = typeof Media; +type MediaViewerType = typeof MediaViewer; type Story = StoryObj; -const meta: Meta = { +const meta = { title: "Components/MediaViewer", - component: Media, + component: MediaViewer, parameters: {}, decorators: [i18nextStoryDecorator], -}; +} satisfies Meta; export default meta; @@ -95,7 +95,7 @@ const DefaultTemplate = (props: MediaViewerProps) => { { return ; }, -}; +} satisfies Story; diff --git a/packages/shared/components/media-viewer/MediaViewer.types.ts b/packages/shared/components/media-viewer/MediaViewer.types.ts index 3cd26c32fd..8dabf674df 100644 --- a/packages/shared/components/media-viewer/MediaViewer.types.ts +++ b/packages/shared/components/media-viewer/MediaViewer.types.ts @@ -55,22 +55,33 @@ export type BoundsType = { export type Point = { x: number; y: number }; export interface MediaViewerProps { + /** Function for translating text. */ t: TranslationType; - + /** List of media files to be displayed. */ files: TFile[]; + /** Specifies whether the media viewer is visible. */ visible: boolean; + /** Position of the current file in the playlist. */ playlistPos: number; + /** Indicates if the current file is a preview. */ isPreviewFile: boolean; + /** List of playlists. */ playlist: PlaylistType[]; + /** List of file extensions that can be previewed as images. */ extsImagePreviewed: string[]; + /** ID of the current file. */ currentFileId: NumberOrString; + /** Function to get the icon for a file based on its size and extension. */ getIcon: (size: number, ext: string, ...arg: unknown[]) => string; - + /** Type of the current device. */ currentDeviceType?: DeviceType; + /** Specifies whether the delete dialog is visible. */ deleteDialogVisible?: boolean; + /** Specifies whether the user has access. */ userAccess?: boolean; + /** ID of the archive room. */ archiveRoomsId?: number; - + /** Context menu items for plugins. */ pluginContextMenuItems?: { key: string; value: { @@ -81,27 +92,46 @@ export interface MediaViewerProps { withActiveItem?: boolean; }; }[]; - + /** Callback function called when the media viewer is closed. */ onClose?: VoidFunction; + /** Callback function called when an error occurs. */ onError?: VoidFunction; + /** Callback function to view the next media file. */ nextMedia?: VoidFunction; + /** Callback function to view the previous media file. */ prevMedia?: VoidFunction; + /** Callback function called on move action. */ onMoveAction?: VoidFunction; + /** Callback function called on copy action. */ onCopyAction?: VoidFunction; + /** Callback function called on copy link action. */ onCopyLink?: ContextMenuAction; + /** Callback function called on duplicate action. */ onDuplicate?: ContextMenuAction; + /** Callback function called on "Download As" action. */ onClickDownloadAs?: VoidFunction; + /** Callback function called on delete action. */ onClickDelete?: ContextMenuAction; + /** Callback function called on download action. */ onClickDownload?: ContextMenuAction; + /** Callback function called on an error when the playlist is empty. */ onEmptyPlaylistError?: VoidFunction; + /** Callback function called on delete action for a specific file. */ onDelete?: (id: NumberOrString) => void; + /** Callback function called on download action for a specific file. */ onDownload?: (id: NumberOrString) => void; + /** Callback function called when the URL changes for a specific file. */ onChangeUrl?: (id: NumberOrString) => void; + /** Callback function called on rename action. */ onClickRename?: OmitSecondArg; + /** Callback function called on preview click action. */ onPreviewClick?: OmitSecondArg; + /** Callback function called on link edit action. */ onClickLinkEdit?: OmitSecondArg; + /** Callback function called on show info panel action. */ onShowInfoPanel?: OmitSecondArg; - + /** Function to set the buffer selection for a file. */ setBufferSelection?: (file?: TFile | null) => void; + /** Function to set the active files based on their IDs. */ setActiveFiles?: (files: number[], destId?: number) => void; }